I’m building a FastAPI backend with websocket and restful endpoints. Since I need to connect it to my frontend on another firebase studio workspace, I use the exposed backend port feature. Thing works fine with http requests, but I face some issues with websocket.
Specifically, using websocat to connect locally works. But any attempt to connect it through the URL given by Firebase studio returns error code 503. I have tried Postman, Insomnia, Hoopscotch, all the same error.
Furthermore, when inspecting the server log (in the attached image), I found out that the client has connected to the websocket server, but then it immediately disconnected. My guess is that the reverse proxy Firebase studio used to forward request to the actually workspace server doesn’t support websocket. It can forward http requests but can’t keep the websocket connection alive, hence the immediately disconnection.
My workaround is to use ngrok to expose the workspace server, then connect to the ngrok endpoint. This method works, indicating that my previous assumption might be correct.
I also found some post about this topic 1 year ago, so this is a longstanding problem. Will it be fixed soon?