Skip to content

Add a timeout for the WebSocket upgrade response - #88

Open
the-mikedavis wants to merge 1 commit into
mainfrom
upgrade-timeout
Open

the-mikedavis wants to merge 1 commit into
mainfrom
upgrade-timeout

Conversation

@the-mikedavis

Copy link
Copy Markdown
Collaborator

Previously, if a server accepted the TCP connection but never responded to the WebSocket upgrade request, the connection would wait forever. The heartbeat timer only starts once the upgrade completes. Mint has a connect timeout, but it only covers opening the TCP/TLS connection.

This change introduces an upgrade_timeout_msec option which defaults to ten seconds (0 to turn off). When that timeout elapses, the connection is closed and c:Slipstream.handle_disconnect/2 is invoked with {:error, :upgrade_timeout}.

Fixes #75

Previously, if a server accepted the TCP connection but never responded
to the WebSocket upgrade request, the connection would wait forever. The
heartbeat timer only starts once the upgrade completes. Mint has a
connect timeout, but it only covers opening the TCP/TLS connection.

This change introduces an `upgrade_timeout_msec` option which defaults
to ten seconds (`0` to turn off). When that timeout elapses, the
connection is closed and  `c:Slipstream.handle_disconnect/2` is invoked
with `{:error, :upgrade_timeout}`.
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.

Connection hangs, does not reconnect with unsuccessful Websocket handshake

1 participant