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

Realtime Stats WebSocket Gets Disconnected After 1 Minute of Inactivity #1663

Open
Elepover opened this issue Feb 2, 2020 · 1 comment
Open

Comments

@Elepover
Copy link

@Elepover Elepover commented Feb 2, 2020

Symptom

Every after exactly 1 exactly minute of inactivity, the WebSocket gets disconnected like this:

image

On servers with a large amount of requests, the problem may not appear for the stats are always being updated quickly and therefore the WebSocket is always active. But on small servers like this one, there is totally possible to have a 1-minute-no-request period.

There have already been an issue discussing about this problem: #1491, I'll talk about that in the Suggested Solution part.

Analysis

It's not GoAccess's fault.

It may be due to the limitation of Firefox, Chrome and possibly other browsers. They kill WebSocket connections that have been inactive for 1 minute. Reference: This StackOverflow Post

Or, it may be nginx's fault for the proxy_read_timeout field.

Suggested Solution

As is described in #1491, extending proxy_read_timeout does work, but it's not the perfect solution since there may be an even longer "no-request period". And extending the period is somehow "bypassing a security feature".

Here are some suggested solutions or "workarounds":

  • Implement a "heartbeat" mechanism on the backend to keep the WebSocket connection alive. (Which has already been mentioned in #1491)
  • Try automatically reconnecting the WebSocket on the frontend.

Edited for some typos :)

@allinurl

This comment has been minimized.

Copy link
Owner

@allinurl allinurl commented Feb 4, 2020

Thanks for reporting this and pointing that out. Like you said (+ here), we could use pings to resolve this or just reconnect when you need to use the socket again. I'm more incline for sending a ping/pong frame.

I can look into this.

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

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.