WebSocket connection to 'ws://localhost:4500/' failed
imarian97 opened this issue · 4 comments
I've configured a local development workspace (based on the VS Code devcontainer feature) where the Firebase Emulators are running inside a container and the code (the dev environment) runs in another. My main container, running the developed apps, can communicate with the emulators, the host machine can access the emulator UI by http://localhost:4000/ so, everything works perfectly with one exception: The logs tab in the Emulators UI shows this error in the console and no logs from the functions emulator:
"WebSocket connection to 'ws://localhost:4500/' failed: Connection closed before receiving a handshake response"
As you can see in the files below all the ports are mapped and exposed, including 4500. I think the problem can be related with some part of the emulator running on 'localhost' instead of '0.0.0.0'. I had similar problems with the emulators not being accessible outside the container and I fixed those by setting "host": "0.0.0.0"
in firebase.json for each emulator.
For the problem described above, I can't find any way to set the host to '0.0.0.0'.
The problem is a bit hard to replicate but I have attached the content of my .devcontainer folder that can be used with Remote-Containers VS Code extension. If it throws some errors about missing files or folders just create them empty or remove the corresponding Docker volumes from docker-compose.
For the problem described above, I can't find any way to set the host to '0.0.0.0'.
You can do that in firebase.json
just like what you do with other emulators.
{
"emulators": {
/* ... other emulators ... */
"logging": {
"host": "0.0.0.0",
"port": 4500,
}
}
}
"logging" is an internal emulator-like process that makes logs available to the Emulator UI.
For the problem described above, I can't find any way to set the host to '0.0.0.0'.
You can do that in
firebase.json
just like what you do with other emulators.{ "emulators": { /* ... other emulators ... */ "logging": { "host": "0.0.0.0", "port": 4500, } } }"logging" is an internal emulator-like process that makes logs available to the Emulator UI.
Thanks, it worked!
I have also added the following config just to be sure.
"hub": {
"host": "0.0.0.0",
"port": 4400,
}
I think it would be great to have more detailed docs in the future for this kind of use-cases.
Great helpful :)
Closing this for now since we have a working solution, but I've filed b/174054841 internally to track improving the configuration / documentation.