firebase uses websocket or SSE

4,859 views
Skip to first unread message

Aditya Mertia

unread,
Jun 10, 2015, 7:10:18 PM6/10/15
to fireba...@googlegroups.com
Hi,

I wanted to clarify my understanding on the communication protocol used by firebase. 
My understanding is that Firebase uses websockets for client - server communication when using client libraries. 
And uses SSE(server sent sockets) for server to client communication(events that act as Push) in case of REST APIs.

Is my understanding correct ?

Thanks
Aditya

Tom Larkworthy

unread,
Jun 10, 2015, 7:22:57 PM6/10/15
to fireba...@googlegroups.com
Yes, clients use websockets with long polling fallback.
SSE = Server Sent Events. Yes, thats an option for the REST API if you want real time updates streamed back. Otherwise you just get typical request-response REST usage. 

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/400f648c-8b56-4b5c-bbfc-f3d22e2be5ce%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Frank van Puffelen

unread,
Jun 10, 2015, 7:23:50 PM6/10/15
to fireba...@googlegroups.com
Hi Aditya,

The Firebase SDKs (JavaScript, Java and Objective-C/Swift) indeed use web sockets for communicating with the Firebase database, with fallback to long-polling.

The Firebase REST API is used with regular HTTP verbs (GET, PUT, POST, DELETE and PATCH) in a request/response fashion. On top of that you can use Firebase's REST streaming API uses SSE (server-sent events) over HTTP.

Are you trying to accomplish something specifically with any of these APIs already? Or is it for now just general inquisitiveness? Both are totally fine btw, just trying to understand the nature of the request.

     Frank

Aditya Mertia

unread,
Jun 12, 2015, 2:38:07 AM6/12/15
to fireba...@googlegroups.com
Thanks Tom, Frank for the response.

Our backend is in python and we have considered using firebase for some usecase that requires realtime communication from client to server. Since firebase doesn't yet 
have client libraries for python so we had used REST API for the same. But since a single client generates a stream of fast requests to firebase its making things slow for us.
Even if we use async requests still the HTTP overheads are causing huge bandwidth usage at our end.

We are using Angular fire and android client libraries for a different usecase of realtime so was curious to know where all things can get slow. In my opinion following scenarios 
can make things slow for us:
1) Internet being slow or jerky. - Technology cannot handle it.
2) Firebase servers sit in US so the whole bandwidth will matter. - Not in our control, we are in India.
3) Complex client side queries in fetching some of the data items. - Can be handled by limiting them and working on local cached data.
4) Initial syncup of bulk data from firebase as our backend pushes data in bulk once a day into firebase. - Can be possibly handled by syncing all data for a day before the user logs in. Not sure if there is a better way to do this. 
5) If there is a bulk update (set of lets say 100 json objects) required from client to server. - Not sure how to handle it

Thanks
Aditya
Reply all
Reply to author
Forward
0 new messages