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

FeatureDefaultWhat
rustlsyesTLS with rustls (ring provider, Mozilla roots from webpki-roots). Pure Rust: no OpenSSL, builds for Android and iOS.
native-tlsnoTLS with the platform library: OpenSSL on Linux, Security.framework on macOS, SChannel on Windows.
platform-verifiernorustls 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.
cookiesnoOne 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).
blockingnosocketio_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 = false and neither rustls nor native-tls, the crate builds without any TLS code; https / wss URLs then fail with TlsNotEnabled.
  • Both. With rustls and native-tls, rustls is the default and a native_tls::TlsConnector passed to tls_config selects native-tls.
  • reqwest's rustls-no-provider. If another crate in your build turns on reqwest 0.13's rustls-no-provider feature (tauri-plugin-updater does), reqwest needs a rustls provider even for plain http: connecting then fails with TlsProviderMissing. Enable rustls here: 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 IncompatibleServer or an InvalidHandshake naming 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.