Class ServletWebSocketConfiguration
java.lang.Object
io.micronaut.servlet.websocket.ServletWebSocketConfiguration
@ConfigurationProperties("micronaut.servlet.websocket")
public class ServletWebSocketConfiguration
extends Object
Configuration for WebSocket support on servlet containers.
Message sizes and the idle timeout are always applied explicitly, because the three supported containers ship different defaults. The values here match those of the Netty server so that behaviour is the same on every runtime.
- Since:
- 6.2.0
- Author:
- graemerocher
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classConfiguration for thepermessage-deflateextension. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final DurationThe default time a client connection's@OnOpenmay take.static final intThe default maximum message size in bytes.static final intThe default number of sends that may be queued before a session reports that it is no longer writable.static final StringThe property used to enable or disable WebSocket support.static final StringThe configuration prefix. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@Nullable Duration@Nullable DurationintintintbooleanvoidsetAsyncSendTimeout(@Nullable Duration asyncSendTimeout) voidvoidsetConnectTimeout(Duration connectTimeout) voidsetEnabled(boolean enabled) voidsetIdleTimeout(@Nullable Duration idleTimeout) voidsetMaxBinaryMessageSize(int maxBinaryMessageSize) voidsetMaxPendingSends(int maxPendingSends) voidsetMaxTextMessageSize(int maxTextMessageSize)
-
Field Details
-
PREFIX
-
ENABLED_PROPERTY
The property used to enable or disable WebSocket support.- See Also:
-
DEFAULT_MAX_MESSAGE_SIZE
public static final int DEFAULT_MAX_MESSAGE_SIZEThe default maximum message size in bytes.- See Also:
-
DEFAULT_MAX_PENDING_SENDS
public static final int DEFAULT_MAX_PENDING_SENDSThe default number of sends that may be queued before a session reports that it is no longer writable.- See Also:
-
DEFAULT_CONNECT_TIMEOUT
The default time a client connection's@OnOpenmay take.
-
-
Constructor Details
-
ServletWebSocketConfiguration
public ServletWebSocketConfiguration()
-
-
Method Details
-
isEnabled
public boolean isEnabled()- Returns:
- Whether WebSocket support is enabled. Defaults to
true.
-
setEnabled
public void setEnabled(boolean enabled) - Parameters:
enabled- Whether WebSocket support is enabled
-
getMaxTextMessageSize
public int getMaxTextMessageSize()- Returns:
- The maximum size in bytes of an inbound text message. Default value (65536).
-
setMaxTextMessageSize
public void setMaxTextMessageSize(int maxTextMessageSize) - Parameters:
maxTextMessageSize- The maximum size in bytes of an inbound text message
-
getMaxBinaryMessageSize
public int getMaxBinaryMessageSize()- Returns:
- The maximum size in bytes of an inbound binary message. Default value (65536).
-
setMaxBinaryMessageSize
public void setMaxBinaryMessageSize(int maxBinaryMessageSize) - Parameters:
maxBinaryMessageSize- The maximum size in bytes of an inbound binary message
-
getIdleTimeout
- Returns:
- How long a session may stay idle before it is closed, or
nullto inheritmicronaut.server.idle-timeout
-
setIdleTimeout
- Parameters:
idleTimeout- How long a session may stay idle before it is closed
-
getAsyncSendTimeout
- Returns:
- How long an asynchronous send may take before it fails, or
nullto use the container default
-
setAsyncSendTimeout
- Parameters:
asyncSendTimeout- How long an asynchronous send may take before it fails
-
getConnectTimeout
- Returns:
- How long
WebSocketContainer#connectToServerwaits for a client endpoint's@OnOpento complete before failing the connection. Default value 30 seconds.
-
setConnectTimeout
- Parameters:
connectTimeout- How longconnectToServerwaits for@OnOpento complete
-
getMaxPendingSends
public int getMaxPendingSends()- Returns:
- The number of queued sends beyond which a session reports that it is not writable. Default value (64).
-
setMaxPendingSends
public void setMaxPendingSends(int maxPendingSends) - Parameters:
maxPendingSends- The number of queued sends beyond which a session reports that it is not writable
-
getCompression
- Returns:
- The per-message compression configuration
-
setCompression
- Parameters:
compression- The per-message compression configuration
-