Class WebSocketClientOptions

    • Field Detail

      • DEFAULT_MAX_MESSAGE_SIZE

        public static final int DEFAULT_MAX_MESSAGE_SIZE
        The default value for maximum WebSocket messages (could be assembled from multiple frames) is 4 full frames worth of data
        See Also:
        Constant Field Values
      • DEFAULT_MAX_CONNECTIONS

        public static final int DEFAULT_MAX_CONNECTIONS
        The default value for the maximum number of WebSocket = 50
        See Also:
        Constant Field Values
      • DEFAULT_SEND_UNMASKED_FRAMES

        public static final boolean DEFAULT_SEND_UNMASKED_FRAMES
        Default WebSocket masked bit is true as depicted by RFC = false
        See Also:
        Constant Field Values
      • DEFAULT_TRY_USE_PER_FRAME_COMPRESSION

        public static final boolean DEFAULT_TRY_USE_PER_FRAME_COMPRESSION
        Default offer WebSocket per-frame deflate compression extension = false
        See Also:
        Constant Field Values
      • DEFAULT_TRY_USE_PER_MESSAGE_COMPRESSION

        public static final boolean DEFAULT_TRY_USE_PER_MESSAGE_COMPRESSION
        Default offer WebSocket per-message deflate compression extension = false
        See Also:
        Constant Field Values
      • DEFAULT_COMPRESSION_LEVEL

        public static final int DEFAULT_COMPRESSION_LEVEL
        Default WebSocket deflate compression level = 6
        See Also:
        Constant Field Values
      • DEFAULT_ALLOW_CLIENT_NO_CONTEXT

        public static final boolean DEFAULT_ALLOW_CLIENT_NO_CONTEXT
        Default offering of the server_no_context_takeover WebSocket parameter deflate compression extension = false
        See Also:
        Constant Field Values
      • DEFAULT_REQUEST_SERVER_NO_CONTEXT

        public static final boolean DEFAULT_REQUEST_SERVER_NO_CONTEXT
        Default offering of the client_no_context_takeover WebSocket parameter deflate compression extension = false
        See Also:
        Constant Field Values
      • DEFAULT_CLOSING_TIMEOUT

        public static final int DEFAULT_CLOSING_TIMEOUT
        Default WebSocket closing timeout = 10 second
        See Also:
        Constant Field Values
      • DEFAULT_MAX_FRAME_SIZE

        public static final int DEFAULT_MAX_FRAME_SIZE
        The default value for maximum WebSocket frame size = 65536 bytes
        See Also:
        Constant Field Values
      • DEFAULT_DEFAULT_HOST

        public static final String DEFAULT_DEFAULT_HOST
        The default value for host name = "localhost"
        See Also:
        Constant Field Values
      • DEFAULT_DEFAULT_PORT

        public static final int DEFAULT_DEFAULT_PORT
        The default value for port = 80
        See Also:
        Constant Field Values
    • Constructor Detail

      • WebSocketClientOptions

        public WebSocketClientOptions()
        Default constructor
      • WebSocketClientOptions

        public WebSocketClientOptions​(WebSocketClientOptions other)
        Copy constructor
        Parameters:
        other - the options to copy
      • WebSocketClientOptions

        public WebSocketClientOptions​(JsonObject json)
        Constructor to create an options from JSON
        Parameters:
        json - the JSON
    • Method Detail

      • getDefaultHost

        public String getDefaultHost()
        Get the default host name to be used by this client in requests if none is provided when making the request.
        Returns:
        the default host name
      • setDefaultHost

        public WebSocketClientOptions setDefaultHost​(String defaultHost)
        Set the default host name to be used by this client in requests if none is provided when making the request.
        Returns:
        a reference to this, so the API can be used fluently
      • getDefaultPort

        public int getDefaultPort()
        Get the default port to be used by this client in requests if none is provided when making the request.
        Returns:
        the default port
      • setDefaultPort

        public WebSocketClientOptions setDefaultPort​(int defaultPort)
        Set the default port to be used by this client in requests if none is provided when making the request.
        Returns:
        a reference to this, so the API can be used fluently
      • isVerifyHost

        public boolean isVerifyHost()
        Is hostname verification (for SSL/TLS) enabled?
        Returns:
        true if enabled
      • setVerifyHost

        public WebSocketClientOptions setVerifyHost​(boolean verifyHost)
        Set whether hostname verification is enabled
        Parameters:
        verifyHost - true if enabled
        Returns:
        a reference to this, so the API can be used fluently
      • isSendUnmaskedFrames

        public boolean isSendUnmaskedFrames()
        Returns:
        true when frame masking is skipped
      • setSendUnmaskedFrames

        public WebSocketClientOptions setSendUnmaskedFrames​(boolean sendUnmaskedFrames)
        Set true when the client wants to skip frame masking.

        You may want to set it true on server by server WebSocket communication: in this case you are by passing RFC6455 protocol.

        It's false as default.

        Parameters:
        sendUnmaskedFrames - true if enabled
        Returns:
        a reference to this, so the API can be used fluently
      • getMaxFrameSize

        public int getMaxFrameSize()
        Get the maximum WebSocket frame size to use
        Returns:
        the max WebSocket frame size
      • setMaxFrameSize

        public WebSocketClientOptions setMaxFrameSize​(int maxFrameSize)
        Set the max WebSocket frame size
        Parameters:
        maxFrameSize - the max frame size, in bytes
        Returns:
        a reference to this, so the API can be used fluently
      • getMaxMessageSize

        public int getMaxMessageSize()
        Get the maximum WebSocket message size to use
        Returns:
        the max WebSocket message size
      • setMaxMessageSize

        public WebSocketClientOptions setMaxMessageSize​(int maxMessageSize)
        Set the max WebSocket message size
        Parameters:
        maxMessageSize - the max message size, in bytes
        Returns:
        a reference to this, so the API can be used fluently
      • getMaxConnections

        public int getMaxConnections()
        Get the maximum of WebSockets per endpoint.
        Returns:
        the max number of WebSockets
      • setMaxConnections

        public WebSocketClientOptions setMaxConnections​(int maxConnections)
        Set the max number of WebSockets per endpoint.
        Parameters:
        maxConnections - the max value
        Returns:
        a reference to this, so the API can be used fluently
      • setTryUsePerFrameCompression

        public WebSocketClientOptions setTryUsePerFrameCompression​(boolean offer)
        Set whether the client will offer the WebSocket per-frame deflate compression extension.
        Parameters:
        offer - true to offer the per-frame deflate compression extension
        Returns:
        a reference to this, so the API can be used fluently
      • getTryUsePerFrameCompression

        public boolean getTryUsePerFrameCompression()
        Returns:
        true when the WebSocket per-frame deflate compression extension will be offered
      • setTryUsePerMessageCompression

        public WebSocketClientOptions setTryUsePerMessageCompression​(boolean offer)
        Set whether the client will offer the WebSocket per-message deflate compression extension.
        Parameters:
        offer - true to offer the per-message deflate compression extension
        Returns:
        a reference to this, so the API can be used fluently
      • getTryUsePerMessageCompression

        public boolean getTryUsePerMessageCompression()
        Returns:
        true when the WebSocket per-message deflate compression extension will be offered
      • setCompressionLevel

        public WebSocketClientOptions setCompressionLevel​(int compressionLevel)
        Set the WebSocket deflate compression level.
        Parameters:
        compressionLevel - the WebSocket deflate compression level
        Returns:
        a reference to this, so the API can be used fluently
      • getCompressionLevel

        public int getCompressionLevel()
        Returns:
        the WebSocket deflate compression level
      • setCompressionAllowClientNoContext

        public WebSocketClientOptions setCompressionAllowClientNoContext​(boolean offer)
        Set whether the client_no_context_takeover parameter of the WebSocket per-message deflate compression extension will be offered.
        Parameters:
        offer - true to offer the client_no_context_takeover parameter
        Returns:
        a reference to this, so the API can be used fluently
      • getCompressionAllowClientNoContext

        public boolean getCompressionAllowClientNoContext()
        Returns:
        true when the client_no_context_takeover parameter for the WebSocket per-message deflate compression extension will be offered
      • setCompressionRequestServerNoContext

        public WebSocketClientOptions setCompressionRequestServerNoContext​(boolean offer)
        Set whether the server_no_context_takeover parameter of the WebSocket per-message deflate compression extension will be offered.
        Parameters:
        offer - true to offer the server_no_context_takeover parameter
        Returns:
        a reference to this, so the API can be used fluently
      • getCompressionRequestServerNoContext

        public boolean getCompressionRequestServerNoContext()
        Returns:
        true when the server_no_context_takeover parameter for the WebSocket per-message deflate compression extension will be offered
      • getClosingTimeout

        public int getClosingTimeout()
        Returns:
        the amount of time (in seconds) a client WebSocket will wait until it closes TCP connection after receiving a close frame
      • setClosingTimeout

        public WebSocketClientOptions setClosingTimeout​(int closingTimeout)
        Set the amount of time a client WebSocket will wait until it closes the TCP connection after receiving a close frame.

        When a WebSocket is closed, the server should close the TCP connection. This timeout will close the TCP connection on the client when it expires.

        Set to 0L closes the TCP connection immediately after receiving the close frame.

        Set to a negative value to disable it.

        Parameters:
        closingTimeout - the timeout is seconds
        Returns:
        a reference to this, so the API can be used fluently
      • isShared

        public boolean isShared()
        Returns:
        whether the pool is shared
      • setShared

        public WebSocketClientOptions setShared​(boolean shared)
        Set to true to share the client.

        There can be multiple shared clients distinguished by getName(), when no specific name is set, the HttpClientOptions.DEFAULT_NAME is used.

        Parameters:
        shared - true to use a shared client
        Returns:
        a reference to this, so the API can be used fluently
      • getName

        public String getName()
        Returns:
        the client name used for sharing
      • setName

        public WebSocketClientOptions setName​(String name)
        Set the client name, used when the client is shared, otherwise ignored.
        Parameters:
        name - the new name
        Returns:
        a reference to this, so the API can be used fluently
      • setTrustAll

        public WebSocketClientOptions setTrustAll​(boolean trustAll)
        Description copied from class: ClientOptionsBase
        Set whether all server certificates should be trusted
        Overrides:
        setTrustAll in class ClientOptionsBase
        Parameters:
        trustAll - true if all should be trusted
        Returns:
        a reference to this, so the API can be used fluently
      • setMetricsName

        public WebSocketClientOptions setMetricsName​(String metricsName)
        Description copied from class: ClientOptionsBase
        Set the metrics name identifying the reported metrics, useful for grouping metrics with the same name.
        Overrides:
        setMetricsName in class ClientOptionsBase
        Parameters:
        metricsName - the metrics name
        Returns:
        a reference to this, so the API can be used fluently
      • setNonProxyHosts

        public WebSocketClientOptions setNonProxyHosts​(List<String> nonProxyHosts)
        Description copied from class: ClientOptionsBase
        Set a list of remote hosts that are not proxied when the client is configured to use a proxy. This list serves the same purpose than the JVM nonProxyHosts configuration.

        Entries can use the * wildcard character for pattern matching, e.g *.example.com matches www.example.com.

        Overrides:
        setNonProxyHosts in class ClientOptionsBase
        Parameters:
        nonProxyHosts - the list of non proxies hosts
        Returns:
        a reference to this, so the API can be used fluently
      • setLocalAddress

        public WebSocketClientOptions setLocalAddress​(String localAddress)
        Description copied from class: ClientOptionsBase
        Set the local interface to bind for network connections. When the local address is null, it will pick any local address, the default local address is null.
        Overrides:
        setLocalAddress in class ClientOptionsBase
        Parameters:
        localAddress - the local address
        Returns:
        a reference to this, so the API can be used fluently
      • setLogActivity

        public WebSocketClientOptions setLogActivity​(boolean logEnabled)
        Description copied from class: NetworkOptions
        Set to true to enabled network activity logging: Netty's pipeline is configured for logging on Netty's logger.
        Overrides:
        setLogActivity in class ClientOptionsBase
        Parameters:
        logEnabled - true for logging the network activity
        Returns:
        a reference to this, so the API can be used fluently
      • setActivityLogDataFormat

        public WebSocketClientOptions setActivityLogDataFormat​(ByteBufFormat activityLogDataFormat)
        Description copied from class: NetworkOptions
        Set the value of Netty's logging handler's data format: Netty's pipeline is configured for logging on Netty's logger.
        Overrides:
        setActivityLogDataFormat in class ClientOptionsBase
        Parameters:
        activityLogDataFormat - the format to use
        Returns:
        a reference to this, so the API can be used fluently
      • setTcpNoDelay

        public WebSocketClientOptions setTcpNoDelay​(boolean tcpNoDelay)
        Description copied from class: TCPSSLOptions
        Set whether TCP no delay is enabled
        Overrides:
        setTcpNoDelay in class ClientOptionsBase
        Parameters:
        tcpNoDelay - true if TCP no delay is enabled (Nagle disabled)
        Returns:
        a reference to this, so the API can be used fluently
      • setTcpKeepAlive

        public WebSocketClientOptions setTcpKeepAlive​(boolean tcpKeepAlive)
        Description copied from class: TCPSSLOptions
        Set whether TCP keep alive is enabled
        Overrides:
        setTcpKeepAlive in class ClientOptionsBase
        Parameters:
        tcpKeepAlive - true if TCP keep alive is enabled
        Returns:
        a reference to this, so the API can be used fluently
      • setSoLinger

        public WebSocketClientOptions setSoLinger​(int soLinger)
        Description copied from class: TCPSSLOptions
        Set whether SO_linger keep alive is enabled
        Overrides:
        setSoLinger in class ClientOptionsBase
        Parameters:
        soLinger - true if SO_linger is enabled
        Returns:
        a reference to this, so the API can be used fluently
      • setIdleTimeout

        public WebSocketClientOptions setIdleTimeout​(int idleTimeout)
        Description copied from class: TCPSSLOptions
        Set the idle timeout, default time unit is seconds. Zero means don't timeout. This determines if a connection will timeout and be closed if no data is received nor sent within the timeout. If you want change default time unit, use TCPSSLOptions.setIdleTimeoutUnit(TimeUnit)
        Overrides:
        setIdleTimeout in class ClientOptionsBase
        Parameters:
        idleTimeout - the timeout
        Returns:
        a reference to this, so the API can be used fluently
      • setReadIdleTimeout

        public WebSocketClientOptions setReadIdleTimeout​(int idleTimeout)
        Description copied from class: TCPSSLOptions
        Set the read idle timeout, default time unit is seconds. Zero means don't timeout. This determines if a connection will timeout and be closed if no data is received within the timeout. If you want change default time unit, use TCPSSLOptions.setIdleTimeoutUnit(TimeUnit)
        Overrides:
        setReadIdleTimeout in class ClientOptionsBase
        Parameters:
        idleTimeout - the read timeout
        Returns:
        a reference to this, so the API can be used fluently
      • setWriteIdleTimeout

        public WebSocketClientOptions setWriteIdleTimeout​(int idleTimeout)
        Description copied from class: TCPSSLOptions
        Set the write idle timeout, default time unit is seconds. Zero means don't timeout. This determines if a connection will timeout and be closed if no data is sent within the timeout. If you want change default time unit, use TCPSSLOptions.setIdleTimeoutUnit(TimeUnit)
        Overrides:
        setWriteIdleTimeout in class ClientOptionsBase
        Parameters:
        idleTimeout - the write timeout
        Returns:
        a reference to this, so the API can be used fluently
      • setReuseAddress

        public WebSocketClientOptions setReuseAddress​(boolean reuseAddress)
        Description copied from class: NetworkOptions
        Set the value of reuse address
        Overrides:
        setReuseAddress in class ClientOptionsBase
        Parameters:
        reuseAddress - the value of reuse address
        Returns:
        a reference to this, so the API can be used fluently
      • setReusePort

        public WebSocketClientOptions setReusePort​(boolean reusePort)
        Description copied from class: NetworkOptions
        Set the value of reuse port.

        This is only supported by native transports.

        Overrides:
        setReusePort in class ClientOptionsBase
        Parameters:
        reusePort - the value of reuse port
        Returns:
        a reference to this, so the API can be used fluently
      • setSslHandshakeTimeout

        public WebSocketClientOptions setSslHandshakeTimeout​(long sslHandshakeTimeout)
        Description copied from class: TCPSSLOptions
        Set the SSL handshake timeout, default time unit is seconds.
        Overrides:
        setSslHandshakeTimeout in class TCPSSLOptions
        Parameters:
        sslHandshakeTimeout - the SSL handshake timeout to set, in milliseconds
        Returns:
        a reference to this, so the API can be used fluently
      • setSslHandshakeTimeoutUnit

        public WebSocketClientOptions setSslHandshakeTimeoutUnit​(TimeUnit sslHandshakeTimeoutUnit)
        Description copied from class: TCPSSLOptions
        Set the SSL handshake timeout unit. If not specified, default is seconds.
        Overrides:
        setSslHandshakeTimeoutUnit in class TCPSSLOptions
        Parameters:
        sslHandshakeTimeoutUnit - specify time unit.
        Returns:
        a reference to this, so the API can be used fluently