public class WebSocketServerConf extends Object
Each config property can be set by the setter method, for example
wsServer.conf().enforceSameOrigin( false );
The setters return `this` for method chaining, for example
wsServer.conf() .enforceSameOrigin( false ) .trafficDump( null ) ;
The config properties must be set before server start.
Instance Methods | |
---|---|
WebSocketServerConf |
enforceSameOrigin(boolean enforceSameOrigin)
Whether to enforce same-origin policy on websocket requests.
|
WebSocketServerConf |
pingInterval(Duration pingInterval)
Interval between server PING requests.
|
WebSocketServerConf |
pingPongTimeout(Duration pingPongTimeout)
Timeout for client PONG response to server PING request.
|
WebSocketServerConf |
inboundBufferSize(int inboundBufferSize)
Inbound data buffer size.
|
WebSocketServerConf |
outboundPayloadMax(long outboundPayloadMax)
Max length of outbound frame payload.
|
WebSocketServerConf |
trafficDump(Consumer<CharSequence> trafficDump)
Where to dump websocket traffic, for debugging purpose.
|
boolean |
get_enforceSameOrigin() |
Duration |
get_pingInterval() |
Duration |
get_pingPongTimeout() |
int |
get_inboundBufferSize() |
long |
get_outboundPayloadMax() |
Consumer<CharSequence> |
get_trafficDump() |
public WebSocketServerConf enforceSameOrigin(boolean enforceSameOrigin)
default: true
If enabled, a websocket handshake request must contain
the "Origin" header that matches the "Host" header,
otherwise the handshake automatically fails with 403
(and WebSocketHandler
will not be invoked).
To support cross-origin requests,
disable enforceSameOrigin, and check "Origin" manually
in WebSocketHandler.handle(WebSocketRequest)
.
public WebSocketServerConf pingInterval(Duration pingInterval)
default: 60 seconds
If a websocket connection has been idle (no inbound/outbound traffic) longer than this interval, the server sends a PING request to the client.
public WebSocketServerConf pingPongTimeout(Duration pingPongTimeout)
default: 15 seconds
After the server sends a PING request to a client
(see pingInterval
),
if no data from the client is received within this timeout,
the websocket connection will be dropped.
Note that any data (not just PONG) from the client would indicate that the client is still responsive.
public WebSocketServerConf inboundBufferSize(int inboundBufferSize)
default: 1024 (1KB)
Even if app is not reading from the client
,
the server still buffers inbound data in background.
This is the limit of that buffer.
This limit can be set to a small value, even 0.
public WebSocketServerConf outboundPayloadMax(long outboundPayloadMax)
default: 16*1024 (16KB)
Outbound frame payload length is also constrained by
outboundBufferSize
(inherited from HttpServerConf).
public WebSocketServerConf trafficDump(Consumer<CharSequence> trafficDump)
default: null
If non-null, websocket inbound/outbound frame info will be dumped to it. This feature is mostly enabled during development time.
public boolean get_enforceSameOrigin()
public Duration get_pingInterval()
public Duration get_pingPongTimeout()
public int get_inboundBufferSize()
public long get_outboundPayloadMax()
public Consumer<CharSequence> get_trafficDump()