Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I force Firebase Realtime Database to use WebSockets?

I know the Firebase Realtime Database web SDK can use either WebSockets or long-polling to talk to the backend servers. Is there a way to force it to only use WebSockets?

like image 689
Michael Lehenbauer Avatar asked Dec 18 '22 06:12

Michael Lehenbauer


1 Answers

In general, you don't want to do this since the Firebase SDK automatically detects whether the client supports WebSockets and will use them if possible. Since WebSockets don't work reliably in all browsers and in all environments (e.g. proxies occasionally don't reliably support WebSocket traffic), forcing WebSocket usage may cause your app to not work reliably in some situations.

As a diagnostic tool or to work around very specific issues, you can force the client to use WebSockets by changing your databaseURL to wss://<app>.firebaseio.com/ instead of https://<app>.firebaseio.com/ but if you find yourself needing to do this, it's probably worth reaching out to support to see if there's a better solution.

like image 146
Michael Lehenbauer Avatar answered Dec 24 '22 02:12

Michael Lehenbauer