My experience with SSEs has been that they are just a half-baked and more limited WebSocket. You handle the SSE stream nearly the same way you would a WS, but you don't get the full benefits of a 2-way protocol. I also had a harder time dealing with errors and connection resets with SSEs than I've ever had with WebSockets.
For the future if I need streaming I'd sooner just go full-on WS over SSE I think, unless there was a really specific reason not to. I don't doubt there are valid reasons to do so, but I can't think of one off the top of my head.
Haven't used either, but it seems like the people at TutaNota had the opposite experience, + improved battery life on SSE for their android app: https://f-droid.org/en/2018/09/03/replacing-gcm-in-tutanota.html This is however for an android app, not a browser app (used as google cloud messaging replacement)
Makes sense. SSE doesn't require the app to do anything. The server pushes to it. Websockets has both client and server "aware" of the other and sending/getting pingbacks, so battery usage is going to be more.
Makes sense. SSE doesn't require the app to do anything. The server pushes to it. Websockets has both client and server "aware" of the other and sending/getting pingbacks, so battery usage is going to be more.
I usually use websockets for my apps, but SSE have the advantage that they can work fine through HTTP2. Amongst other things this makes initial session establishment quite a bit faster
12
u/GuinnessDraught Jun 13 '19
My experience with SSEs has been that they are just a half-baked and more limited WebSocket. You handle the SSE stream nearly the same way you would a WS, but you don't get the full benefits of a 2-way protocol. I also had a harder time dealing with errors and connection resets with SSEs than I've ever had with WebSockets.
For the future if I need streaming I'd sooner just go full-on WS over SSE I think, unless there was a really specific reason not to. I don't doubt there are valid reasons to do so, but I can't think of one off the top of my head.