Client
Errors
One typed, cloneable Error; engine errors; what each one means.
Every fallible call returns socketio_next::Result<T> with one Error type. It is #[non_exhaustive], Clone (errors can be stored in states and shared), and its messages never contain URLs or query values.
socket.io errors
| Variant | When |
|---|---|
ConnectRejected { message, data } | the server's connect_error: the namespace middleware called next(new Error(message)) (data is err.data), or the namespace does not exist. Not retried. |
ConnectTimeout(d) | handshake + upgrade + CONNECT took longer than timeout |
IncompatibleServer | the server answered CONNECT without a session id: a Socket.IO v2 server |
InvalidAuth(..) | auth is not a JSON object, or auth_with panicked |
NotConnected | emit while disconnected (without buffer_while_disconnected) |
Closed | the client is closed |
AckTimeout(d) | no ack within the timeout of emit_with_ack |
Disconnected | the connection was lost before the ack arrived |
ReservedEvent(name) | emitting a reserved name (connect, connect_error, disconnect, disconnecting, newListener, removeListener) |
InvalidUrl, InvalidHeader, Json, Protocol | bad input, a JSON conversion, a packet that does not decode |
Engine(engineio::Error) | the transport layer, below |
Engine errors
engineio::Error | When |
|---|---|
HttpStatus { status, message } | a non-200 answer; message is engine.io's {"code", "message"} error text, None for any other body |
WebsocketClosed { code, reason } | the server or a proxy closed the websocket with a close frame |
ProxyFailed(..) | the proxy refused the tunnel, or is not an http:// proxy |
Timeout(d) | a transport step timed out |
PingTimeout | no ping within pingInterval + pingTimeout |
UpgradeUnavailable, UpgradeFailed(..) | the websocket upgrade is not offered or the probe failed |
InvalidHandshake(..) | not an Engine.IO v4 handshake (an Engine.IO v3 server says so) |
TlsNotEnabled(..) | https / wss without a TLS feature |
TlsProviderMissing | reqwest's rustls-no-provider is on and rustls is not (TLS) |
InvalidTlsConfig(..) | the TLS configuration could not be built (bad PEM, unsupported protocol versions) |
Http(..), Websocket(..) | the underlying reqwest / tungstenite error |
InvalidUrl, InvalidUrlScheme(..) | not http, https, ws or wss |
use socketio_next::{Error, engineio};
match client_builder.connect().await {
Ok(client) => { /* ... */ }
Err(Error::ConnectRejected { message, data, .. }) => eprintln!("refused: {message} {data:?}"),
Err(Error::Engine(engineio::Error::HttpStatus { status, .. })) => eprintln!("HTTP {status}"),
Err(err) => eprintln!("{err}"),
}
See Debugging for what to check for each error.