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

Timeout Error #76

Closed
dtjohnson opened this issue Oct 21, 2016 · 15 comments
Closed

Timeout Error #76

dtjohnson opened this issue Oct 21, 2016 · 15 comments

Comments

@dtjohnson
Copy link

Very nice library!

Could you explain why you are throwing an error here:
https://github.com/Yaffle/EventSource/blob/master/eventsource.js#L601

I have a global error handler that displays errors to the user and this keeps triggering the error handler.

@Yaffle
Copy link
Owner

Yaffle commented Oct 22, 2016

I want to show that you are not sending messages every 45 seconds. This is needed to detect disconnects.

@Leonidnei
Copy link

How do I overcome this exception?

@darrenscerri
Copy link

Send a heartbeat at least every 45 seconds to keep connection alive.

@fperezgaliana
Copy link

Hi! I know the server should send a 'heartbeat' every few seconds, but is there a way to avoid the console.error message?
imagen

I've tried handling the error like this:

es.addEventListener("error", (error) => {
        console.log("Error in SSE connection", error);
        
        return false;
      });

But it didn't make any change. Thanks.

@Yaffle
Copy link
Owner

Yaffle commented Mar 2, 2018

@fperezgaliana ,
The code change is needed to.

May be, console.log() should be used here at line 596 - https://github.com/Yaffle/EventSource/blob/master/src/eventsource.js#L596

@karser
Copy link

karser commented Jul 25, 2019

Hello, I'm also getting Error: No activity within 45000 milliseconds. Reconnecting.. This is indeed annoying that you can't catch this error. I'd be happy if it's possible.
On another hand, the native EventSource also requires heartbeat, so it's better to enable it on your backend.

@Yaffle
Copy link
Owner

Yaffle commented Jul 25, 2019

@karser, native EventSource may use TCP keepalives , I think

@farukhali
Copy link

I am experiencing a strange issue, for some clients connection is timing out though we are sending heartbeat. It's working fine for most of the users but for some users connection keep timing out. Most of these users are using Chrome latest version, any thoughts?

@Yaffle
Copy link
Owner

Yaffle commented Dec 7, 2019

@farukhali , do you receive some other events? can you check on the client side if there is something unusual? if you are using plain text HTTP some antivirus software may block streaming responses.

@farukhali
Copy link

farukhali commented Dec 9, 2019

@Yaffle normal http requests are working fine. No event received through SSE. Content type for this request is text/event-stream; charset=utf-8. I also suspect antivirus/firewall but it's difficult to get connected with a customer having this problem.

@akaskj
Copy link

akaskj commented Jan 30, 2020

@farukhali @Yaffle I am facing the exact same issue, even though I am sending heartbeats every 15 seconds I am seeing this error thrown every 45 seconds. We also send other data as soon as the connection is established and even that data is not received by the customer.

@farukhali were you able to find a fix or a workaround for it?

@warrendodsworth
Copy link

warrendodsworth commented May 25, 2020

To suppress the error use preventDefault()

es.addEventListener("error", (e) => {
        console.log("Error in SSE connection", error);
        e.preventDefault()
});

@kaesetoast
Copy link

@warrendodsworth it seems like this does not work any more. I did not check yet when it broke, but it works fine with 1.0.12. I just tried to implement this in a project using 1.0.22 and now the error-object is missing a preventDefault-function.

@kaesetoast
Copy link

I just realized that you don't actually throw a real error any more. So if I read your code right, there is no need to suppress anything really. I guess this can be closed then?

@Yaffle
Copy link
Owner

Yaffle commented Feb 18, 2021

@kaesetoast , seems, so

@Yaffle Yaffle closed this as completed Feb 18, 2021
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

10 participants