Eventsource API : EXCEPTION: No activity within 300000 milliseconds. Reconnecting

我的未来我决定 提交于 2019-12-13 04:22:54

问题


I am using eventSource API and added the addEventListener() to the eventsouce. The event source is activated till only 45 seconds. I want to keep the connection alive until the server send the response back to client.

Now, I am getting the below exception because there is no response back from the server till 45 secs.

EXCEPTION: No activity within 300000 milliseconds. Reconnecting.

Please give me some pointers to make the connection alive/ any other approach to achieve it.


回答1:


The solution is to send data periodically, even null bytes work and will keep the connection alive.

If the connection can not be established and you want to retry connecting, it is possible to use setTimeout set for instance to 45 seconds.

Once the connection is established use clearTimeout to stop trying.



来源:https://stackoverflow.com/questions/50449599/eventsource-api-exception-no-activity-within-300000-milliseconds-reconnectin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!