socket.io-client 4.8.0 automatic reconnect is not working
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 63.2k
- Forks
- 10.3k
- Avg merge
- 11d 20h
- Merged PRs (30d)
- 2
Description
Describe the bug
I have a client which connects to server
If the server stops and restarts the connect event is not called anymore
In version 4.7.5 the connect event was called when the server restarts and opens the websocket
Socket.IO client version: 4.8.0
Expected behavior
The connect event should be called automatically if the server restarts and opens the websocket
Platform:
NodeJs 16 on Ubuntu 20.04
and also in Chromium 128.0.6613.119
Additional context
On 4.7.5 I get multiple times this connect_error event until it reconnects.
TransportError: xhr poll error
at Polling.onError (/home/sruetzler/data/workspace/gitlab/target/installer/rauc-api-client/node_modules/engine.io-client/build/cjs/transport.js:47:37)
at Request.<anonymous> (/home/sruetzler/data/workspace/gitlab/target/installer/rauc-api-client/node_modules/engine.io-client/build/cjs/transports/polling.js:238:18)
at Request.Emitter.emit (/home/sruetzler/data/workspace/gitlab/target/installer/rauc-api-client/node_modules/@socket.io/component-emitter/lib/cjs/index.js:143:20)
at Request.onError (/home/sruetzler/data/workspace/gitlab/target/installer/rauc-api-client/node_modules/engine.io-client/build/cjs/transports/polling.js:343:14)
at Timeout._onTimeout (/home/sruetzler/data/workspace/gitlab/target/installer/rauc-api-client/node_modules/engine.io-client/build/cjs/transports/polling.js:316:30)
at listOnTimeout (node:internal/timers:557:17)
at processTimers (node:internal/timers:500:7) {
description: 0,
context: XMLHttpRequest {
UNSENT: 0,
OPENED: 1,
HEADERS_RECEIVED: 2,
LOADING: 3,
DONE: 4,
readyState: 4,
onreadystatechange: [Function (anonymous)],
responseText: 'Error: connect ECONNREFUSED 192.168.70.132:443\n' +
' at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1161:16)',
responseXML: '',
status: 0,
statusText: Error: connect ECONNREFUSED 192.168.70.132:443
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1161:16) {
errno: -111,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '192.168.70.132',
port: 443
},
open: [Function (anonymous)],
setDisableHeaderCheck: [Function (anonymous)],
setRequestHeader: [Function (anonymous)],
getResponseHeader: [Function (anonymous)],
getAllResponseHeaders: [Function (anonymous)],
getRequestHeader: [Function (anonymous)],
send: [Function (anonymous)],
handleError: [Function (anonymous)],
abort: [Function (anonymous)],
addEventListener: [Function (anonymous)],
removeEventListener: [Function (anonymous)],
dispatchEvent: [Function (anonymous)]
},
type: 'TransportError'
}
on 4.8.0 I get this errror once and after that I get this endless
No transports available
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
Reproduce the reconnect behavior with socket.io-client 4.8.0 and compare it with 4.7.5, checking the engine.io-client paths mentioned in the trace, including build/cjs/transport.js and transports/polling.js. Done means the client retries after the server restarts, emits connect again, and does not enter the endless “No transports available” state.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nodejs, typescript
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100