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

MethodTargetsDefaultPage
secure() / unsecure()allsecureConnecting
with_port(i32)allthe scheme’s portConnecting
with_hub(String)allthe hub argumentConnecting
authenticate_basic(String, Option<String>)allnoneAuthentication
authenticate_bearer(String)allnoneAuthentication
with_access_token_factory(async fn)allnoneAuthentication
with_default_credentials(), with_credentials(user, password, domain)nativenoneAuthentication

#Negotiation, transports and HTTP

MethodTargetsDefaultPage
skip_negotiation()allnegotiateConnecting
with_transports(Transports)allTransports::all()Transports
with_long_polling_timeout(Duration)all100 sTransports
with_http_version(HttpVersion)nativeHttpVersion::AutoTransports
with_header(name, value)all (browsers: fetch only)noneConnecting
with_request_hook(Fn(&mut HttpRequest))all (browsers: fetch only)noneConnecting
with_invocation_headers(hook)allnoneCalling the hub
with_cookie_jar(CookieJar)nativea jar per clientConnecting
with_runtime_handle(Handle)nativethe ambient runtimePlatforms

#Protocol and message size

MethodTargetsDefaultPage
with_messagepack_protocol()all, messagepack featureJSONHub protocols
with_maximum_message_size(usize)allunboundedHub protocols

#Timers

MethodTargetsDefaultPage
with_keep_alive_interval(Duration)all15 sLifecycle
with_server_timeout(Duration)all30 sLifecycle
with_handshake_timeout(Duration)all15 sLifecycle
with_connect_timeout(Duration)all120 sLifecycle
with_close_timeout(Duration)all5 sLifecycle

#Reconnection

MethodTargetsDefaultPage
with_reconnection_policy(ReconnectionConfig)allnever reconnectReconnection
with_disconnection_handler(handler)allnoneReconnection
with_stateful_reconnect(StatefulReconnectConfig)alloffReconnection

#TLS and proxies

MethodTargetsDefaultPage
with_tls_config_hook(Fn(&mut rustls::ClientConfig))native, TLS featuresnoneTLS
with_additional_root_certificates_pem(pem)nativenoneTLS
with_client_certificate(chain_pem, key_pem)nativenoneTLS
use_webpki_roots()native, tls-webpki-rootsthe platform verifierTLS
with_proxy(url), with_system_proxy(), without_proxy()nativethe system proxyProxies
with_os_proxy()nativethe default also reads the environment variablesProxies
with_proxy_auto_config(url)native, proxy-pac (not iOS)noneProxies

#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.