Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript WebSocket into Firebase?

Is it possible to use standard WebSocket's to access a Firebase database instead of using their library. Specifically, I want to access the firebase real-time database using only vanilla javascript. Is that even feasible?

like image 245
nicholas Avatar asked Feb 11 '18 17:02

nicholas


People also ask

Can you use WebSockets with Firebase?

You won't have to make individual WebSocket calls since one socket connection is all you need. All of your data syncs automatically through the single WebSocket as fast as your client's network can carry it and Firebase sends you new data as and when it's updated.

Can you proxy WebSockets?

WebSocket over a Forward Proxy. WebSocket communication can take successfully take place in the presence of forward proxies, providing the client and proxy server have been configured properly to deal with it.

What is the difference between WebSocket and socket IO?

Key Differences between WebSocket and socket.ioIt provides the Connection over TCP, while Socket.io is a library to abstract the WebSocket connections. WebSocket doesn't have fallback options, while Socket.io supports fallback. WebSocket is the technology, while Socket.io is a library for WebSockets.

Can we use REST API with WebSocket?

Yes. You can use REST over WebSocket with library like SwaggerSocket.


Video Answer


1 Answers

In most modern browsers the Firebase client communicates with its back-end over web sockets. But the wire protocol it uses is not documented, and may change over time. Then again, you could study the open-source JavaScript SDK to get a pretty good idea of how it works under the hood.

Alternatively, you could build your custom client library on top of the Firebase REST API, which is fully documented. It includes support for Streaming from the REST API, which gets you many of the advantages of the Web Socket implementation without relying on an undocumented protocol.

like image 74
Frank van Puffelen Avatar answered Oct 14 '22 23:10

Frank van Puffelen