socketio / socket.io

Realtime application framework (Node.JS server)
https://socket.io
MIT License
61.25k stars 10.12k forks source link

Add transport: server-sent events #5078

Open jntesteves opened 5 years ago

jntesteves commented 5 years ago

Note: for support questions, please use one of these channels: stackoverflow or slack

You want to:

Current behaviour

The transports available are http polling and websocket.

Steps to reproduce (if the current behaviour is a bug)

N/A

Expected behaviour

To have the option of a new transport available: sse (server-sent events)

Setup

Other information (e.g. stacktraces, related issues, suggestions how to fix)

Server-sent events have existed for many years now as an option to push events from the server to the browser [1]. It is the ideal mechanism for some use-cases and has the potential to greatly save on power usage on mobile devices [2]. This is the sole transport used by Mercure [3], a new protocol for real-time communications that I believe might become a direct competitor to Socket.io.

[1] https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events [2] https://www.smashingmagazine.com/2018/02/sse-websockets-data-flow-http2/ [3] https://github.com/dunglas/mercure

sergejostir commented 4 years ago

There were PRs opened to add this years ago, but they never got merged. https://github.com/socketio/socket.io/pull/732 https://github.com/socketio/socket.io-client/pull/378

Probably a good starting point to make a transport for current version.

Leo-Mu commented 4 years ago

Yes! This is a much-needed feature.

mrfelfel commented 3 years ago

related to socketio/socket.io#5075