pub struct WebSocketClient { /* private fields */ }Expand description
A WebSocketTransport that opens client WebSockets over TCP, with TLS
for wss:.
Pair it with a FetchPolicy in a WebSocketService: the policy
authorizes the origins JavaScript connects to, and this transport
resolves their hosts and refuses any resolved address that is not
public, such as loopback, private and link-local networks, unless
allow_private_addresses. A host that
resolves to no allowed address fails with PermissionDenied.
The opening handshake asks for the subprotocols JavaScript requested and
carries the service’s credential headers; tungstenite performs it and
the framing, answers pings and validates the server’s selection. No
extensions are requested. Limits::channel_message_bytes bounds each
message and frame from the server. Connecting and relaying run on the
Tokio runtime that polls the host pump; an App without one fails each
connection with Configuration. TLS verifies the server against the
Mozilla roots in webpki-roots, or the configuration from
with_tls_config.
Implementations§
Source§impl WebSocketClient
impl WebSocketClient
Sourcepub fn new() -> Self
pub fn new() -> Self
Connect to public addresses, verifying wss: servers against the
webpki-roots certificates.
Sourcepub fn with_tls_config(config: Arc<ClientConfig>) -> Self
pub fn with_tls_config(config: Arc<ClientConfig>) -> Self
Connect to public addresses, using config for wss:, such as one
that trusts a private certificate authority.
Sourcepub fn allow_private_addresses(self) -> Self
pub fn allow_private_addresses(self) -> Self
Also connect to loopback, private and other non-public addresses, for a host whose services run beside it.