public final class WebSocketClientConfig extends Object
WebSocket clients.
Instances are normally created via the associated builder. The configuration controls timeouts, maximum frame and message sizes, fragmentation behaviour and optional automatic responses to PING frames.
Unless explicitly overridden, reasonable defaults are selected for desktop and server environments. For mobile or memory-constrained deployments, consider adjusting buffer sizes and queue limits.
| Modifier and Type | Class and Description |
|---|---|
static class |
WebSocketClientConfig.Builder
Builder for
WebSocketClientConfig. |
| Modifier and Type | Method and Description |
|---|---|
static WebSocketClientConfig.Builder |
custom()
Creates a new builder instance with default settings.
|
Timeout |
getCloseWaitTimeout()
Socket timeout used while waiting for the peer to complete the close handshake.
|
Timeout |
getConnectTimeout()
Timeout used for establishing the initial TCP/TLS connection.
|
int |
getMaxFrameSize()
Maximum accepted WebSocket frame payload size.
|
int |
getMaxFramesPerTick()
Limit of frames written per reactor "tick".
|
long |
getMaxMessageSize()
Maximum accepted message size after fragment reassembly (and after decompression if enabled).
|
int |
getMaxOutboundControlQueue()
Maximum number of queued outbound control frames.
|
long |
getMaxOutboundDataBytes()
Upper bound for the total number of bytes queued for outbound data frames.
|
Integer |
getOfferServerMaxWindowBits()
Optional value for
server_max_window_bits in the PMCE offer. |
int |
getOutgoingChunkSize()
Preferred outgoing fragmentation chunk size.
|
List<String> |
getSubprotocols()
Ordered list of WebSocket subprotocols offered to the server via
Sec-WebSocket-Protocol. |
boolean |
isAutoPong()
Whether the client automatically responds to PING frames with a PONG frame.
|
boolean |
isDirectBuffers()
Whether direct byte buffers are preferred for internal I/O.
|
boolean |
isHttp2Enabled()
Returns
true if HTTP/2 Extended CONNECT (RFC 8441) is enabled. |
boolean |
isOfferClientNoContextTakeover()
Whether the client offers the
client_no_context_takeover PMCE parameter. |
boolean |
isOfferServerNoContextTakeover()
Whether the client offers the
server_no_context_takeover PMCE parameter. |
boolean |
isPerMessageDeflateEnabled()
Whether the client offers the
permessage-deflate extension during the handshake. |
public Timeout getConnectTimeout()
null if the caller wants to rely on defaultspublic List<String> getSubprotocols()
Sec-WebSocket-Protocol.
The server may select at most one. The client should treat a server-selected protocol that was not offered as a handshake failure.
null)public boolean isPerMessageDeflateEnabled()
permessage-deflate extension during the handshake.true if PMCE is offered, false otherwisepublic boolean isOfferServerNoContextTakeover()
server_no_context_takeover PMCE parameter.true if the parameter is included in the offerpublic boolean isOfferClientNoContextTakeover()
client_no_context_takeover PMCE parameter.true if the parameter is included in the offerpublic Integer getOfferServerMaxWindowBits()
server_max_window_bits in the PMCE offer.
Valid values are in range 8..15 when non-null. This value limits the server's compressor; the client decoder can accept any 8..15 value.
server_max_window_bits, or null if not offeredpublic int getMaxFrameSize()
If an incoming frame exceeds this limit, the implementation should treat it as a protocol violation and initiate a close with an appropriate close code.
public int getOutgoingChunkSize()
Outgoing messages larger than this value may be fragmented into multiple frames.
public int getMaxFramesPerTick()
This is a fairness control to reduce the risk of starving the reactor thread when a large backlog exists.
public boolean isDirectBuffers()
true for direct buffers, false for heap bufferspublic boolean isAutoPong()
true if auto-PONG is enabledpublic Timeout getCloseWaitTimeout()
null)public long getMaxMessageSize()
public int getMaxOutboundControlQueue()
This bounds memory usage and prevents unbounded growth of control traffic under backpressure.
public long getMaxOutboundDataBytes()
When this limit is exceeded, sendText/sendBinary return false
and the data frame is rejected. A value of 0 disables the limit.
public boolean isHttp2Enabled()
true if HTTP/2 Extended CONNECT (RFC 8441) is enabled.public static WebSocketClientConfig.Builder custom()
Copyright © 1999–2021 The Apache Software Foundation. All rights reserved.