Configuration reference
Every ConnectionConfiguration method with its targets, default and the page that explains it.
ConnectionConfiguration is the closure argument of SignalRClient::new and connect_with. Every method takes &mut self and returns &ConnectionConfiguration, so call them as separate statements. “Native” means every non-WASM target.
use std::time::Duration;
use dxn_signalr::SignalRClient;
fn configured() -> Result<SignalRClient, dxn_signalr::Error> {
SignalRClient::new("hub.example.com", "chat", |c| {
c.with_port(8443);
c.authenticate_bearer("<access token>".to_string());
c.with_server_timeout(Duration::from_secs(60));
})
}
The defaults are https/wss on the scheme’s port, JSON, no authentication, every transport in the server’s order, the system proxy (native) and no automatic reconnection.
#Endpoint and authentication
| Method | Targets | Default | Page |
|---|---|---|---|
secure() / unsecure() | all | secure | Connecting |
with_port(i32) | all | the scheme’s port | Connecting |
with_hub(String) | all | the hub argument | Connecting |
authenticate_basic(String, Option<String>) | all | none | Authentication |
authenticate_bearer(String) | all | none | Authentication |
with_access_token_factory(async fn) | all | none | Authentication |
with_default_credentials(), with_credentials(user, password, domain) | native | none | Authentication |
#Negotiation, transports and HTTP
| Method | Targets | Default | Page |
|---|---|---|---|
skip_negotiation() | all | negotiate | Connecting |
with_transports(Transports) | all | Transports::all() | Transports |
with_long_polling_timeout(Duration) | all | 100 s | Transports |
with_http_version(HttpVersion) | native | HttpVersion::Auto | Transports |
with_header(name, value) | all (browsers: fetch only) | none | Connecting |
with_request_hook(Fn(&mut HttpRequest)) | all (browsers: fetch only) | none | Connecting |
with_invocation_headers(hook) | all | none | Calling the hub |
with_cookie_jar(CookieJar) | native | a jar per client | Connecting |
with_runtime_handle(Handle) | native | the ambient runtime | Platforms |
#Protocol and message size
| Method | Targets | Default | Page |
|---|---|---|---|
with_messagepack_protocol() | all, messagepack feature | JSON | Hub protocols |
with_maximum_message_size(usize) | all | unbounded | Hub protocols |
#Timers
| Method | Targets | Default | Page |
|---|---|---|---|
with_keep_alive_interval(Duration) | all | 15 s | Lifecycle |
with_server_timeout(Duration) | all | 30 s | Lifecycle |
with_handshake_timeout(Duration) | all | 15 s | Lifecycle |
with_connect_timeout(Duration) | all | 120 s | Lifecycle |
with_close_timeout(Duration) | all | 5 s | Lifecycle |
#Reconnection
| Method | Targets | Default | Page |
|---|---|---|---|
with_reconnection_policy(ReconnectionConfig) | all | never reconnect | Reconnection |
with_disconnection_handler(handler) | all | none | Reconnection |
with_stateful_reconnect(StatefulReconnectConfig) | all | off | Reconnection |
#TLS and proxies
| Method | Targets | Default | Page |
|---|---|---|---|
with_tls_config_hook(Fn(&mut rustls::ClientConfig)) | native, TLS features | none | TLS |
with_additional_root_certificates_pem(pem) | native | none | TLS |
with_client_certificate(chain_pem, key_pem) | native | none | TLS |
use_webpki_roots() | native, tls-webpki-roots | the platform verifier | TLS |
with_proxy(url), with_system_proxy(), without_proxy() | native | the system proxy | Proxies |
with_os_proxy() | native | the default also reads the environment variables | Proxies |
with_proxy_auto_config(url) | native, proxy-pac (not iOS) | none | Proxies |
#Validation
new validates everything that does not need the network and fails with ErrorKind::Configuration, whose setting() names the option. Liveness durations are never rejected: values that cannot work are logged as warnings. See Errors for the complete list.
#Next
Errors lists what each call and phase can fail with.