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
  • Field Details

    • PREFIX

      public static final String PREFIX
      The configuration prefix.
      See Also:
    • ENABLED_PROPERTY

      public static final String ENABLED_PROPERTY
      The property used to enable or disable WebSocket support.
      See Also:
    • DEFAULT_MAX_MESSAGE_SIZE

      public static final int DEFAULT_MAX_MESSAGE_SIZE
      The default maximum message size in bytes.
      See Also:
    • DEFAULT_MAX_PENDING_SENDS

      public static final int DEFAULT_MAX_PENDING_SENDS
      The default number of sends that may be queued before a session reports that it is no longer writable.
      See Also:
    • DEFAULT_CONNECT_TIMEOUT

      public static final Duration DEFAULT_CONNECT_TIMEOUT
      The default time a client connection's @OnOpen may 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

      public @Nullable Duration getIdleTimeout()
      Returns:
      How long a session may stay idle before it is closed, or null to inherit micronaut.server.idle-timeout
    • setIdleTimeout

      public void setIdleTimeout(@Nullable Duration idleTimeout)
      Parameters:
      idleTimeout - How long a session may stay idle before it is closed
    • getAsyncSendTimeout

      public @Nullable Duration getAsyncSendTimeout()
      Returns:
      How long an asynchronous send may take before it fails, or null to use the container default
    • setAsyncSendTimeout

      public void setAsyncSendTimeout(@Nullable Duration asyncSendTimeout)
      Parameters:
      asyncSendTimeout - How long an asynchronous send may take before it fails
    • getConnectTimeout

      public Duration getConnectTimeout()
      Returns:
      How long WebSocketContainer#connectToServer waits for a client endpoint's @OnOpen to complete before failing the connection. Default value 30 seconds.
    • setConnectTimeout

      public void setConnectTimeout(Duration connectTimeout)
      Parameters:
      connectTimeout - How long connectToServer waits for @OnOpen to 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

      public void setCompression(ServletWebSocketConfiguration.CompressionConfiguration compression)
      Parameters:
      compression - The per-message compression configuration