socket.io icon indicating copy to clipboard operation
socket.io copied to clipboard

Add transport: server-sent events

Open jntesteves opened this issue 6 years ago • 3 comments

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

You want to:

  • [ ] report a bug
  • [x] request a feature

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

  • OS: Any
  • browser: Any (Edge requires a polyfill)
  • engine.io version: 3.4.0

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

jntesteves avatar Sep 26 '19 17:09 jntesteves

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.

sergejostir avatar Dec 31 '19 12:12 sergejostir

Yes! This is a much-needed feature.

Leo-Mu avatar Jun 22 '20 06:06 Leo-Mu

related to socketio/socket.io#5075

mrfelfel avatar Jan 22 '21 07:01 mrfelfel