tpeczek/Lib.AspNetCore.ServerSentEvents

Support for IE/Edge

Closed this issue · 1 comments

Since IE/Edge don't support SSE, you have to use a polyfill (like this one). The problem is that since the polyfill uses long polling, once a message is sent, everything between that last message and the moment the connection establishes again, is lost.

I'm not quite sure how to solve this, since you will have to be able to

  • store a queue of items since the last sent message (at least for a short time)
  • be able to track unequivocally the browser connecting to the library.

The first one should be easy. As for the second, maybe you can provide an option so the browser has to send some kind of ID somewhere (headers, query string) that you can use to track this behavior. This also will be useful for browsers that DO support SSE but are under a bad connection (so they may disconnect and reconnect, not as often as IE, but...)

What do you think?

The SSE standard has a defined way of handling reconnects. It is based on dedicated Last-Event-ID request header. The EventSource API (the client side for SSE) takes care of reconnecting and sending this header automatically if there are some connectivity problems. Any polyfill for SSE should be using exactly this mechanism (the one you have linked confirms that in the README).

This library provides basic support for reconnects. In general you have to create your own Server​Sent​Events​Service (derived from the one which comes with this library) and implement OnReconnectAsync. This is the place when you can hook your own store for events (providing a "one size fits all" solution would be impossible so the library doesn't attempt to do so) and send the ones which client has missed.