allinurl / allinurl/goaccess

Realtime Stats WebSocket Gets Disconnected After 1 Minute of Inactivity

Open
#1,663 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

add websocket-server
Dominant language
C
Stars
20.9k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

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 :)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by examining the existing realtime stats WebSocket handling and the related discussion in issue #1491; the payload names no specific files or tests. Compare a backend heartbeat with frontend reconnection, then verify that an idle connection remains usable or reconnects after the reported one-minute inactivity period.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
backend, frontend, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.