Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Low level compatibility? #6

Open
wmertens opened this issue Aug 10, 2019 · 1 comment
Open

Low level compatibility? #6

wmertens opened this issue Aug 10, 2019 · 1 comment

Comments

@wmertens
Copy link

I believe that the real EventSource sets the TCP keepalive of the connection so it can idle for longer. I'm not sure if this can be set just on the server side.

I wonder how using sse.js impacts the hard problems with streams, namely knowing if you are still connected, and reconnecting automatically.

I am looking for a nice way to do GraphQL subscriptions over HTTP/2, and websockets seem too complex. Much simpler to return an event stream for each POST subscription and letting HTTP/2 multiplex them. Automatic reconnecting would be wonderful.

@djgamerr
Copy link

djgamerr commented Aug 5, 2024

sse.addEventListener("error", () => {
// as the docs say, this only fires if there is an error with the event, manual closing is handled by "abort"
sse.stream(); // try to re-open the stream
});

this is as basic as it gets, create a simple module that will do this, maybe add a retry counter and a try/catch block in case the stream() fails to open.

Use sse.readyState and check if the state is not 2 before you re-do the connection

something like this, i don't think its such a big deal to create a reconnection functionality based on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants