#[non_exhaustive]pub struct WsConfig {Show 20 fields
pub enabled: bool,
pub max_connections: usize,
pub max_connections_per_user: usize,
pub max_connections_per_ip: usize,
pub max_pending_connections: usize,
pub roles_refresh_secs: u64,
pub handshakes_per_ip_per_minute: u32,
pub auth_timeout_secs: u64,
pub ping_interval_secs: u64,
pub idle_timeout_secs: u64,
pub request_timeout_secs: u64,
pub write_timeout_secs: u64,
pub outbox_frames: usize,
pub frames_per_second: u32,
pub frame_burst: u32,
pub max_message_bytes: usize,
pub read_buffer_bytes: usize,
pub max_rooms_per_connection: usize,
pub max_room_members: usize,
pub query_token: bool,
}Expand description
[ws]: the WebSocket hub at /v1/ws (see crate::ws).
The socket buffers are tuned for many idle connections: an 8 KiB read buffer, no write
buffering (each frame is written at once) and the protocol’s 1 MiB message limit. Defaults
follow the protocol (AUTH_TIMEOUT_SECS, MAX_MESSAGE_BYTES, the chat room caps).
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.enabled: boolServe the hub at /v1/ws. Default true; when false the path answers 403 (never 400).
max_connections: usizeThe most open sockets (authenticated or not); a handshake over it gets 503 + Retry-After.
Default 10 000. Keep it below the process’s open-file limit.
max_connections_per_user: usizeThe most sockets per user; a newer one closes the oldest with 4009 (replaced), the oldest of its own session first. Default 5.
max_connections_per_ip: usizeThe most open sockets per client address (IPv6 by /64), authenticated or not; 429 above. Default 100 (players behind one NAT or at a LAN party share an address).
max_pending_connections: usizeThe most sockets still waiting for their first-message auth (anonymous for up to
auth_timeout_secs); 503 above, so they never crowd out authenticated players. Default 1000.
roles_refresh_secs: u64How often the hub re-reads the roles of every connected user, in seconds (role changes made by another process, e.g. the command line, reach open sockets within this). Changes made in this process apply at once. Default 60, 0 = off.
handshakes_per_ip_per_minute: u32WebSocket handshakes per client address (IPv6 by /64) per minute; 429 above. Default 60, 0 = off.
auth_timeout_secs: u64Seconds an unauthenticated socket has to send auth (then close 1008). Default 5 (the
protocol’s AUTH_TIMEOUT_SECS).
ping_interval_secs: u64Seconds between the server’s pings. Default 20 (the client pings every 15 s itself).
idle_timeout_secs: u64Seconds without any frame from the client (data, ping or pong) before the socket counts
as dead and is dropped. Default 60 (must exceed ping_interval_secs).
request_timeout_secs: u64The time limit of one request handler, in seconds (then 503 unavailable). Default 10.
write_timeout_secs: u64How long one frame may take to write before the peer counts as stuck (the socket is dropped), in seconds. Default 10.
outbox_frames: usizeFrames waiting to be sent per socket (pushes): the largest burst the game may push to one socket at once. While a request handler runs, as many again are held back (they follow its answer). When both are full the socket is closed with 1013 (the client reconnects and resyncs). Raise it for broadcast-heavy games. Default 256.
frames_per_second: u32Incoming frames per second per socket (sustained); over it a request is answered
rate_limited, and a socket that keeps flooding is closed with 1008. Default 20.
frame_burst: u32Incoming frames a socket may send at once (the bucket size). Default 40.
max_message_bytes: usizeThe largest message in either direction, in bytes (a bigger incoming one closes the socket
with 1009). Default 1 MiB (the protocol’s MAX_MESSAGE_BYTES and the client’s default).
read_buffer_bytes: usizeThe socket’s read buffer, in bytes. Default 8 KiB (tungstenite’s own default, 128 KiB per socket, costs ~120 KiB more per idle connection).
max_rooms_per_connection: usizeThe most rooms one socket may be in at once (Hub::join). Default 16 (the protocol’s
DEFAULT_MAX_JOINED_ROOMS).
max_room_members: usizeThe most sockets in one room unless the room is joined with its own cap. Default 200 (the
protocol’s DEFAULT_MAX_ROOM_MEMBERS).
query_token: boolAccept the access token as ?token= on the handshake. Default false: reverse proxies (Caddy,
nginx) log URLs with their query, so a token there ends up in access logs. Clients that cannot
set headers (browsers) use first-message auth instead.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for WsConfig
impl<'de> Deserialize<'de> for WsConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for WsConfig
impl RefUnwindSafe for WsConfig
impl Send for WsConfig
impl Sync for WsConfig
impl Unpin for WsConfig
impl UnsafeUnpin for WsConfig
impl UnwindSafe for WsConfig
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more