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

Every 45000 milliseconds retry request again and again #193

Open
MrJimmyYi opened this issue Sep 24, 2021 · 5 comments
Open

Every 45000 milliseconds retry request again and again #193

MrJimmyYi opened this issue Sep 24, 2021 · 5 comments

Comments

@MrJimmyYi
Copy link

I met a problem: "No activity within 45000 milliseconds. Reconnecting"
I use EventSourcePolyfill.But the background response time may take 5 minutes more than 45 seconds by default.
I tried many methods, but they are all failed. How to set its reconnection time according to custom Settings?

@MrJimmyYi
Copy link
Author

Hi! I found a solution in eventsource.js

> eventsource.js

function start(es, url, options){
...
var heartbeatTimeout = parseDuration(options.heartbeatTimeout, 45000);
...
}
Look! Our default 45000 and custom heartbeat times are here.

So, I tried to modify this line of code , Here is my modified code:
var heartbeatTimeout = parseDuration(options.headers.heartbeatTimeout, 45000);

Then I added heartbeatTimeout in the header to specify 3 minutes:
new EventSourcePolyfill(url,{ headers: { heartbeatTimeout: 180*1000 } })

Because I'm using Spring SseEmitter ,the server also sets a timeout period of 10 minutes:
SseEmitter sseEmitter = new SseEmitter(600000L);

This means I retry to connect to the server every 3 minutes during the 10-minute validity period

So, it worked,Won't retry to connect the server every 45 seconds, using a custom 5-minute time limit for requests instead. Perfect!
b81f135b8cc5a229631e7c794259e11e
ab02c55471cd6a298e5204068f64449c

@udhayakumarcp
Copy link

image

@cwirz
Copy link

cwirz commented Jan 12, 2022

@udhayaas97 i switched to use this package instead: https://www.npmjs.com/package/eventsource

@sanketkarandikar
Copy link

sanketkarandikar commented Mar 31, 2022

@MrJimmyYi I tried your solution, but no matter what changes I do in eventSource.js and pass heartbeatTimeout in headers, it is not reflecting. What could be wrong?

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

4 participants