Getting started
Installation
Add socketio-next, pick a TLS backend and the optional features.
Cargo.toml
[dependencies]
socketio-next = "0.1"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
serde_json = "1"
The client runs on tokio. serde_json is only needed for json! and Value in your own code.
Cargo features
| Feature | Default | What |
|---|---|---|
rustls | yes | TLS with rustls (ring provider, Mozilla roots from webpki-roots). Pure Rust: no OpenSSL, builds for Android and iOS. |
native-tls | no | TLS with the platform library: OpenSSL on Linux, Security.framework on macOS, SChannel on Windows. |
platform-verifier | no | rustls checks certificates with the operating system's trust store (enterprise and user-installed CAs) through rustls-platform-verifier, instead of the bundled Mozilla roots. Not on Android (it needs JVM setup there), which keeps the bundled roots. |
cookies | no | One cookie jar per client: cookies set by polling answers go back on later requests and on the websocket handshake (sticky sessions behind a load balancer). |
blocking | no | socketio_next::blocking: the same client with blocking methods and plain-closure handlers. |
# native-tls instead of rustls
socketio-next = { version = "0.1", default-features = false, features = ["native-tls"] }
# rustls with the OS trust store, cookies and the blocking API
socketio-next = { version = "0.1", features = ["platform-verifier", "cookies", "blocking"] }
TLS backends
- Without TLS. With
default-features = falseand neitherrustlsnornative-tls, the crate builds without any TLS code;https/wssURLs then fail withTlsNotEnabled. - Both. With
rustlsandnative-tls, rustls is the default and anative_tls::TlsConnectorpassed totls_configselects native-tls. - reqwest's
rustls-no-provider. If another crate in your build turns on reqwest 0.13'srustls-no-providerfeature (tauri-plugin-updaterdoes), reqwest needs a rustls provider even for plainhttp: connecting then fails withTlsProviderMissing. Enablerustlshere: it hands reqwest a ring-based configuration, no global provider needed.
Requirements
- Rust 1.85 (edition 2024), see MSRV.
- A Socket.IO v3 or v4 server (Engine.IO v4). socket.io 2.x servers (Engine.IO v3) fail with
IncompatibleServeror anInvalidHandshakenaming Engine.IO v3.
Tauri
For a Tauri 2 app add the plugin instead; it re-exports the client crate as tauri_plugin_socketio::socketio_next. See Tauri plugin setup.