My client sockets disconnect with a "ping timeout" reason after a few hours of connection and can't connect again
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 63.2k
- Forks
- 10.3k
- Avg merge
- 11d 20h
- Merged PRs (30d)
- 2
Description
Hi, i'm having a bit of a issue with my project. I'm building an app that will stay opened at all times in the device, with a non-stop connection through the sockets. However lately, all of my sockets disconnect and can't reconnect. I managed to print some logs from the device and here it is :
As you can see on the screenshot, the socket connection starts at around 1:30 AM and then is disconnectd at 7:30 AM, but manages to reconnect each time until 9:14 where it disconnects and then can't reconnect with the reason "ping timeout".
I'm not sure where is the problem here. I'm using Angular 17 with ngx-socket-io version 4.6.1. In my backend i use NestJS with socket-io 4.7.2.
Since this problem that happend this morning i did theses steps to try to fix the problem (i haven't tried it yet) :
- Upgraded my NestJS from v9 (a year old) to v10 (including the @nestjs/websockets package)
- Upgraded socket-io in my NestJS from 4.7.2 to 4.7.5
- Added a pingTimeout of 60000 to my WebSocketGateway (maybe this will fix it ??)
Any idea what could be causing the problem ? Also it's important to note than in my APP i have an interval that tries to connect to the socket every minute just in case it's disconnected, but as you can see on the logs, it can't even reconnect 🤔
Edit: Also important to note that it's only 4 cuccurent connections. With 1 CPU and 2GB of RAM. With NGINX and PM2 for my API.
@darrachequesne
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reported logs and the long-lived Angular 17/ngx-socket-io client against the NestJS backend, then compare disconnect and reconnect behavior with the listed NGINX and PM2 setup. Done means the ping-timeout cause is identified and the client reconnects reliably after hours; the issue provides no named file or test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- angular, nginx, node.js, typescript
- Domain
- backend, devops, networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100