Issue: recv() failed (104: Connection reset by peer) while proxying/upgrading WebSocket in NGINX with Socket.IO
Maintainer antworten meist innerhalb von 2 Tagen
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 35/100
- Issue-Typ
- Bug
- Klarheit
- Muss geklärt werden
- Aktivitätsstatus
- Ruhig
- Tech-Stack
- nginx, node.js
- Bereich
- backend, networking
Rechercherichtung
Beginnen Sie mit der gezeigten NGINX-Konfiguration für location /socket.io/ und korrelieren Sie deren Fehlerprotokolle mit den Socket.IO-Serverprotokollen und clientseitigen Verbindungsabbrüchen während WebSocket-Upgrades. Als abgeschlossen gilt die Ermittlung, ob der Client, das Netzwerk, NGINX oder der Node.js/Socket.IO-Server die Verbindung zurücksetzt, belegt durch diagnostische Traces.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Describe the bug
We're encountering the following NGINX errors while using it as a reverse proxy to a Node.js server running Socket.IO. These errors occur during WebSocket connections.
1. While proxying upgraded WebSocket connection:
*10088819 recv() failed (104: Connection reset by peer) while proxying upgraded connection, client: <internal-ip>, server: , request: "GET /socket.io/?EIO=4&transport=websocket HTTP/1.1", upstream: "http://127.0.0.1:8080/socket.io/?EIO=4&transport=websocket", host: "<hostname>"
2. While reading response header from upstream:
*13983419 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: <internal-ip>, server: , request: "GET /socket.io/?EIO=4&transport=websocket HTTP/1.1", upstream: "http://127.0.0.1:8080/socket.io/?EIO=4&transport=websocket", host: "<hostname>"
Environment
- Node.js: 18.x
- Socket.IO: 4.7.4
- NGINX: 1.28.0
- Deployment: NGINX as a reverse proxy to a Node.js server
- Transport: WebSocket (transport=websocket)
- Clients: Mobile app (Socket.IO client)
What We’ve Checked
- These errors consistently occur randomly.
- Socket.IO server logs do not show any corresponding exceptions or disconnect messages.
- Other HTTP (non-WebSocket) traffic through NGINX works without issues.
- No known memory or CPU bottlenecks on the Node.js server.
- No aggressive timeouts or buffer limits are configured in NGINX.
Current NGINX Configuration
location /socket.io/ {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_pass http://nodes;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_connect_timeout 75s;
proxy_send_timeout 75s;
proxy_read_timeout 75s;
proxy_buffering off;
proxy_request_buffering off;
}
Questions / Guidance Needed
- We’re seeking help to understand and troubleshoot this behavior. Specifically:
- What are the common causes of recv() failed (104: Connection reset by peer) in a Socket.IO + NGINX setup, particularly during WebSocket upgrades?
- Is it possible for the Socket.IO server to terminate a connection without logging it?
- How can we distinguish whether the disconnect is triggered by the client, network, NGINX, or Socket.IO server?
- What debugging strategies or additional logging/tracing can help us isolate the root cause?
Additional Context
- Issue is strictly limited to WebSocket transport.
- NGINX and Node.js server are hosted on the same machine (127.0.0.1 backend).
- Client devices are stable and do not indicate network issues at their end.
- Please let us know what diagnostics or traces from the Socket.IO server we can enable to better trace or isolate this.
Thanks in advance for your help!
- Vorherrschende Sprache
- TypeScript
- Sterne
- 63.2k
- Forks
- 10.2k
- Ø Merge
- 6 T. 4 Std.
- Gemergte PRs (30 T.)
- 6
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus socketio/socket.io
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
Maintainer antworten meist innerhalb von 2 Tagen
-
Raise Engine.IO minimum to 6.6.10 for published security fixesEvtl. vergeben @harshit-exe-dev hat das vor 28 Tagen übernommen. Offen
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 2 Tagen
-
Can't set response headers in Server.handleUpgradeEvtl. vergeben @MsfPablo hat das vor 89 Tagen übernommen. Offenquestion
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
socketio/socket.io#5497 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 2 Tagen
-
WebTransport ignores query parameters in URLEvtl. vergeben @cyphercodes hat das vor 177 Tagen übernommen. Offenneeds major release question
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
socketio/socket.io#5496 · 3 Kommentare ·
Maintainer antworten meist innerhalb von 2 Tagen
-
cleanupEmptyChildNamespaces releases a child namespace while a socket is in its middleware, and the cleanup unregisters a newer namespace by nameEvtl. vergeben @Jeremiah-D hat das vor 5 Tagen übernommen. Offen
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 54/100
Maintainer antworten meist innerhalb von 2 Tagen
Alle Issues in socketio/socket.io
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
excalidraw/excalidraw#12590 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
Automattic/data-liberation-agent#1657 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 79/100
HGInsights/hgi-cli#23 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Impact: 3-Minor Scope: Core
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 74/100
sugarlabs/musicblocks-v4#1029 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 2 Tagen