DEV Community

Discussion on: Say Goodbye to WebSockets? Why SSE Might Be Your New Best Friend

Collapse
 
peerreynders profile image
peerreynders

SSE is simplest described as a regular HTTP request with a streaming response; the streaming payload is events.

  • The server closing the response is unexpected, so the client sends another request to start again.
  • The client will close the connection when it is done with the request.

WS requests on the other hand convert (โ€œupgradeโ€) the HTTP request to something outside of the HTTP spec to get access to the sockets that the original HTTP request was using.

In both cases the server has to manage a distinct connection to each user; however SSE connections tend to be less demanding on server resources and SSE may work where WS won't; like when firewalls block non-HTTP traffic. But both require an always-on server,so neither of them is suitable for a serverless environment.

Collapse
 
5p4r70n profile image
jothish

Ok, go it

The server and client will keep this connection alive for future server-to-client event notifications.

Thanks! ๐Ÿ˜Š