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

VariantWhen
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
IncompatibleServerthe server answered CONNECT without a session id: a Socket.IO v2 server
InvalidAuth(..)auth is not a JSON object, or auth_with panicked
NotConnectedemit while disconnected (without buffer_while_disconnected)
Closedthe client is closed
AckTimeout(d)no ack within the timeout of emit_with_ack
Disconnectedthe connection was lost before the ack arrived
ReservedEvent(name)emitting a reserved name (connect, connect_error, disconnect, disconnecting, newListener, removeListener)
InvalidUrl, InvalidHeader, Json, Protocolbad input, a JSON conversion, a packet that does not decode
Engine(engineio::Error)the transport layer, below

Engine errors

engineio::ErrorWhen
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
PingTimeoutno 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
TlsProviderMissingreqwest'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.