connectionTimeout property

int? connectionTimeout
getter/setter pair

Connection timeout period.

The maximum time in milliseconds a connection attempt may take to establish the network connection to the broker: the TCP connect and, for a secure connection, the TLS handshake. If it elapses the attempt fails with a NoConnectionException, as a refused connection or a failed handshake does, and the socket is never used.

Unlike socketTimeout, which bounds the TCP connect only, this also bounds the TLS handshake, so a peer that accepts the TCP connection but never completes the handshake cannot hold a connection attempt indefinitely. It does not change connectTimeoutPeriod, the wait for the broker's connection acknowledgement once connected.

The Dart runtime cannot abort a TLS handshake in progress, so a socket that completes its handshake after the timeout is destroyed when it does.

For a websocket connection it bounds the TCP connect, the TLS handshake of a wss connection and the websocket upgrade, so a broker or network that accepts the connection but never answers the upgrade cannot hold a connection attempt, or an auto reconnect, indefinitely. A websocket that connects after the timeout is closed when it does and is never used.

For TCP, secure TCP and websocket connections. The alternate websocket implementation, see useAlternateWebSocketImplementation, is not covered. Defaults to null, no timeout.

Implementation

int? connectionTimeout;