pub struct WsProxy { /* private fields */ }Expand description
WebSocket reverse proxy with round-robin load balancing.
Accepts HTTP/1.1 WebSocket upgrade requests and tunnels traffic to one of the configured backends.
Backend URL schemes:
"host:port"— plain TCP (no scheme)"ws://host:port"— plain TCP (port defaults to 80)"wss://host:port"— TLS (port defaults to 443); requires thehttp-clientorhttp2Cargo feature
Call WsProxy::bind to start. It blocks the calling thread indefinitely.
Implementations§
Source§impl WsProxy
impl WsProxy
Sourcepub fn new<I, S>(backends: I) -> Self
pub fn new<I, S>(backends: I) -> Self
Create a proxy that distributes connections across backends in
round-robin order.
Each entry may be "host:port", "ws://host:port", or
"wss://host:port". wss:// requires the http-client or http2
Cargo feature.
Sourcepub fn connect_timeout_ms(self, ms: u64) -> Self
pub fn connect_timeout_ms(self, ms: u64) -> Self
Override the TCP connect timeout to each backend (default: 5 s).
Sourcepub fn read_timeout_ms(self, ms: u64) -> Self
pub fn read_timeout_ms(self, ms: u64) -> Self
Override the idle read timeout on client connections (default: 30 s).
For wss:// backends this controls the outer idle timeout on the
client side; the internal polling interval is fixed at 5 ms.
Auto Trait Implementations§
impl Freeze for WsProxy
impl RefUnwindSafe for WsProxy
impl Send for WsProxy
impl Sync for WsProxy
impl Unpin for WsProxy
impl UnsafeUnpin for WsProxy
impl UnwindSafe for WsProxy
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more