Log WebSocket connection-attempt timeout as a warning, not an exception#213
Merged
sierpinskid merged 1 commit intoJun 29, 2026
Merged
Conversation
WebsocketClient.ConnectAsync guards the native ClientWebSocket.ConnectAsync with a timeout (it can hang on some Unity/Android versions). On timeout it throws TimeoutException, which HandleConnectionFailedAsync routes to the catch-all else branch and logs via _logs.Exception(...) (Debug.LogException) — i.e. at error severity. A connection-attempt timeout is an expected, transient failure that the reconnect flow recovers from, so reporting it as an exception floods crash/error reporting tools (Sentry, Bugsnag, etc.) with handled, non-actionable noise. Treat TimeoutException like the other expected connection-failure types and log it as a warning instead.
Contributor
Author
|
@sierpinskid the PR we discussed for turning 3 second timeout into a warning instead of error |
sierpinskid
approved these changes
Jun 29, 2026
Member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Log a WebSocket connection-attempt timeout as a warning instead of surfacing it as an exception.
Background
WebsocketClient.ConnectAsyncguards the nativeClientWebSocket.ConnectAsyncwith a timeout (it can hang indefinitely on some Unity/Android versions, and token cancellation doesn't reliably interrupt it). When the guard trips, it throws aTimeoutException:That exception is caught and passed to
HandleConnectionFailedAsync, where it doesn't match the "expected" set (OperationCanceledException/WebSocketException/SocketException) and therefore falls through to the catch-all branch:Problem
A connection-attempt timeout is an expected, transient failure that the reconnect flow recovers from — but logging it via
_logs.Exception(Debug.LogException) reports it at error severity. In production this floods crash/error-reporting tools (Sentry, Bugsnag, etc.) with handled, non-actionable noise, especially on flaky networks where the initial connect occasionally exceeds the timeout before reconnecting successfully.Change
Treat
TimeoutExceptionlike the other expected connection-failure types and log it as a warning instead:ConnectionFailedis still raised exactly as before, so reconnect behavior is unchanged — only the log severity of the timeout case is reduced. Genuine, unexpected connection exceptions still go through_logs.Exception.Notes
TimeoutExceptiononly; no other failure path is affected.IWebsocketClient, and no test asserts on the log severity ofHandleConnectionFailedAsync.