Skip to content

feat: Apply connectionTimeout to websocket connections (#651) - #652

Merged
shamblett merged 1 commit into
masterfrom
pr651
Oct 15, 2026
Merged

shamblett merged 1 commit into
masterfrom
pr651

Conversation

@shamblett

Copy link
Copy Markdown
Owner

connectionTimeout bounds the TCP connect and TLS handshake of TCP and secure TCP connections, but a websocket connection opened with WebSocket.connect had no bound at all, in connect and in connectAuto. A broker or network that accepts the connection but never answers the websocket upgrade (common when a mobile network comes back, or on a Wi-Fi without internet) held the attempt forever. During an auto reconnect that also held the auto reconnect itself: it never made another attempt, so the client stayed in the connecting state even after the network was back.

connectionTimeout now also applies to the default websocket implementation: the TCP connect, the TLS handshake of a wss connection and the websocket upgrade, in connect and in connectAuto. When it elapses the attempt fails with a NoConnectionException through the existing failed connect path, and the auto reconnect moves on to its next attempt. A websocket that connects after the timeout is closed when it does and is never used.

With connectionTimeout unset the behaviour is unchanged. The alternate websocket implementation is not covered.

connectionTimeout bounds the TCP connect and TLS handshake of TCP and secure
TCP connections, but a websocket connection opened with WebSocket.connect had
no bound at all, in connect and in connectAuto. A broker or network that
accepts the connection but never answers the websocket upgrade (common when a
mobile network comes back, or on a Wi-Fi without internet) held the attempt
forever. During an auto reconnect that also held the auto reconnect itself: it
never made another attempt, so the client stayed in the connecting state even
after the network was back.

connectionTimeout now also applies to the default websocket implementation:
the TCP connect, the TLS handshake of a wss connection and the websocket
upgrade, in connect and in connectAuto. When it elapses the attempt fails with
a NoConnectionException through the existing failed connect path, and the auto
reconnect moves on to its next attempt. A websocket that connects after the
timeout is closed when it does and is never used.

With connectionTimeout unset the behaviour is unchanged. The alternate
websocket implementation is not covered.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@shamblett
shamblett merged commit aa29ba4 into master Oct 15, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants