io.vertx.core.http

## Class WebSocketConnectOptions

- java.lang.Object
- - io.vertx.core.http.RequestOptions
  - - io.vertx.core.http.WebSocketConnectOptions

-     public class WebSocketConnectOptions
      extends RequestOptions

  Options describing how an `HttpClient` connect a `WebSocket`.
  Author:
    Julien Viet

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static boolean` | `DEFAULT_ALLOW_ORIGIN_HEADER` The default WebSocket allow origin header = `true`
    `static ProxyOptions` | `DEFAULT_PROXY_OPTIONS` The default value for proxy options = `null`
    `static boolean` | `DEFAULT_REGISTER_WRITE_HANDLERS` Whether write-handlers should be registered by default = false.
    `static List<String>` | `DEFAULT_SUB_PROTOCOLS` The default WebSocket sub protocols = `null`
    `static WebsocketVersion` | `DEFAULT_VERSION` The default WebSocket version = `WebsocketVersion.V13`

    - ### Fields inherited from class io.vertx.core.http.RequestOptions

      `DEFAULT_CONNECT_TIMEOUT, DEFAULT_FOLLOW_REDIRECTS, DEFAULT_HOST, DEFAULT_HTTP_METHOD, DEFAULT_IDLE_TIMEOUT, DEFAULT_PORT, DEFAULT_SERVER, DEFAULT_SSL, DEFAULT_TIMEOUT, DEFAULT_URI`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `WebSocketConnectOptions()`
    `WebSocketConnectOptions(JsonObject json)`
    `WebSocketConnectOptions(WebSocketConnectOptions other)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `WebSocketConnectOptions` | `addHeader(CharSequence key, CharSequence value)` Add a request header.
    `WebSocketConnectOptions` | `addHeader(CharSequence key, Iterable<CharSequence> values)`
    `WebSocketConnectOptions` | `addHeader(String key, String value)` Add a request header.
    `WebSocketConnectOptions` | `addSubProtocol(String subprotocol)` Add a WebSocket sub protocol to use.
    `boolean` | `getAllowOriginHeader()`
    `ProxyOptions` | `getProxyOptions()` Get the proxy options override for connections
    `List<String>` | `getSubProtocols()`
    `WebsocketVersion` | `getVersion()`
    `boolean` | `isRegisterWriteHandlers()`
    `WebSocketConnectOptions` | `putHeader(CharSequence key, CharSequence value)` Set a request header.
    `WebSocketConnectOptions` | `putHeader(CharSequence key, Iterable<CharSequence> values)`
    `WebSocketConnectOptions` | `putHeader(String key, String value)` Set a request header.
    `WebSocketConnectOptions` | `setAbsoluteURI(String absoluteURI)` Parse an absolute URI to use, this will update the `ssl`, `host`, `port` and `uri` fields.
    `WebSocketConnectOptions` | `setAbsoluteURI(URL url)` Like `RequestOptions.setAbsoluteURI(String)` but using an `URL` parameter.
    `WebSocketConnectOptions` | `setAllowOriginHeader(boolean allowOriginHeader)` Set whether to add the `origin` header to the WebSocket handshake request, enabled by default.
    `WebSocketConnectOptions` | `setConnectTimeout(long timeout)` Sets the amount of time after which, if the request is not obtained from the client within the timeout period, the `Future<HttpClientRequest>` obtained from the client is failed with a `TimeoutException`.
    `WebSocketConnectOptions` | `setFollowRedirects(Boolean followRedirects)` Set whether to follow HTTP redirect
    `WebSocketConnectOptions` | `setHeaders(MultiMap headers)` Set request headers from a multi-map.
    `WebSocketConnectOptions` | `setHost(String host)` Set the host name to be used by the client request.
    `WebSocketConnectOptions` | `setIdleTimeout(long timeout)` Sets the amount of time after which if the WebSocket handshake does not happen within the timeout period an `WebSocketHandshakeException` will be passed to the exception handler and the connection will be closed.
    `WebSocketConnectOptions` | `setMethod(HttpMethod method)` Set the HTTP method to be used by the client request.
    `WebSocketConnectOptions` | `setPort(Integer port)` Set the port to be used by the client request.
    `RequestOptions` | `setProxyOptions(ProxyOptions proxyOptions)` Override the `HttpClientOptions.setProxyOptions(ProxyOptions)` proxy options for connections.
    `WebSocketConnectOptions` | `setRegisterWriteHandlers(boolean registerWriteHandlers)` Whether write-handlers should be registered on the `EventBus`.
    `WebSocketConnectOptions` | `setServer(SocketAddress server)` Set the server address to be used by the client request.
    `WebSocketConnectOptions` | `setSsl(Boolean ssl)` Set whether SSL/TLS is enabled.
    `WebSocketConnectOptions` | `setSubProtocols(List<String> subProtocols)` Set the WebSocket sub protocols to use.
    `WebSocketConnectOptions` | `setTimeout(long timeout)` Sets the amount of time after which if the WebSocket handshake does not happen within the timeout period an `WebSocketHandshakeException` will be passed to the exception handler and the connection will be closed.
    `WebSocketConnectOptions` | `setTraceOperation(String op)` Override the operation the tracer use for this request.
    `WebSocketConnectOptions` | `setURI(String uri)` Set the request relative URI.
    `WebSocketConnectOptions` | `setVersion(WebsocketVersion version)` Set the WebSocket version.
    `JsonObject` | `toJson()`

    - ### Methods inherited from class io.vertx.core.http.RequestOptions

      `getConnectTimeout, getFollowRedirects, getHeaders, getHost, getIdleTimeout, getMethod, getPort, getServer, getTimeout, getTraceOperation, getURI, isSsl, removeHeader, removeHeader`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### DEFAULT_PROXY_OPTIONS

          public static final ProxyOptions DEFAULT_PROXY_OPTIONS

      The default value for proxy options = `null`

    - #### DEFAULT_VERSION

          public static final WebsocketVersion DEFAULT_VERSION

      The default WebSocket version = `WebsocketVersion.V13`

    - #### DEFAULT_SUB_PROTOCOLS

          public static final List<String> DEFAULT_SUB_PROTOCOLS

      The default WebSocket sub protocols = `null`

    - #### DEFAULT_ALLOW_ORIGIN_HEADER

          public static final boolean DEFAULT_ALLOW_ORIGIN_HEADER

      The default WebSocket allow origin header = `true`
      See Also:
        Constant Field Values

    - #### DEFAULT_REGISTER_WRITE_HANDLERS

          public static final boolean DEFAULT_REGISTER_WRITE_HANDLERS

      Whether write-handlers should be registered by default = false.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### WebSocketConnectOptions

          public WebSocketConnectOptions()

    - #### WebSocketConnectOptions

          public WebSocketConnectOptions(WebSocketConnectOptions other)

    - #### WebSocketConnectOptions

          public WebSocketConnectOptions(JsonObject json)

  - ### Method Detail

    - #### getVersion

          public WebsocketVersion getVersion()

      Returns:
        the WebSocket version

    - #### setVersion

          public WebSocketConnectOptions setVersion(WebsocketVersion version)

      Set the WebSocket version.
      Returns:
        a reference to this, so the API can be used fluently

    - #### getSubProtocols

          public List<String> getSubProtocols()

      Returns:
        the list of WebSocket sub protocols or `null` if there are none

    - #### setSubProtocols

          public WebSocketConnectOptions setSubProtocols(List<String> subProtocols)

      Set the WebSocket sub protocols to use.
      Returns:
        a reference to this, so the API can be used fluently

    - #### addSubProtocol

          public WebSocketConnectOptions addSubProtocol(String subprotocol)

      Add a WebSocket sub protocol to use.
      Returns:
        a reference to this, so the API can be used fluently

    - #### getProxyOptions

          public ProxyOptions getProxyOptions()

      Get the proxy options override for connections
      Overrides:
        `getProxyOptions` in class `RequestOptions`
      Returns:
        proxy options override

    - #### setProxyOptions

          public RequestOptions setProxyOptions(ProxyOptions proxyOptions)

      Override the `HttpClientOptions.setProxyOptions(ProxyOptions)` proxy options for connections.
      Overrides:
        `setProxyOptions` in class `RequestOptions`
      Parameters:
        `proxyOptions` - proxy options override object
      Returns:
        a reference to this, so the API can be used fluently

    - #### getAllowOriginHeader

          public boolean getAllowOriginHeader()

      Returns:
        whether to add the `origin` header to the WebSocket handshake request

    - #### setAllowOriginHeader

          public WebSocketConnectOptions setAllowOriginHeader(boolean allowOriginHeader)

      Set whether to add the `origin` header to the WebSocket handshake request, enabled by default.

      Set to `false` when a server does not accept WebSocket with an origin header.

      Parameters:
        `allowOriginHeader` - whether to add the `origin` header to the WebSocket handshake request
      Returns:
        a reference to this, so the API can be used fluently

    - #### setHost

          public WebSocketConnectOptions setHost(String host)

      Description copied from class: `RequestOptions`
      Set the host name to be used by the client request.
      Overrides:
        `setHost` in class `RequestOptions`
      Returns:
        a reference to this, so the API can be used fluently

    - #### setPort

          public WebSocketConnectOptions setPort(Integer port)

      Description copied from class: `RequestOptions`
      Set the port to be used by the client request.
      Overrides:
        `setPort` in class `RequestOptions`
      Returns:
        a reference to this, so the API can be used fluently

    - #### setSsl

          public WebSocketConnectOptions setSsl(Boolean ssl)

      Description copied from class: `RequestOptions`
      Set whether SSL/TLS is enabled.
      Overrides:
        `setSsl` in class `RequestOptions`
      Parameters:
        `ssl` - true if enabled
      Returns:
        a reference to this, so the API can be used fluently

    - #### setURI

          public WebSocketConnectOptions setURI(String uri)

      Description copied from class: `RequestOptions`
      Set the request relative URI.
      Overrides:
        `setURI` in class `RequestOptions`
      Parameters:
        `uri` - the relative uri
      Returns:
        a reference to this, so the API can be used fluently

    - #### setTimeout

          public WebSocketConnectOptions setTimeout(long timeout)

      Sets the amount of time after which if the WebSocket handshake does not happen within the timeout period an `WebSocketHandshakeException` will be passed to the exception handler and the connection will be closed.
      Overrides:
        `setTimeout` in class `RequestOptions`
      Parameters:
        `timeout` - the amount of time in milliseconds.
      Returns:
        a reference to this, so the API can be used fluently

    - #### setConnectTimeout

          public WebSocketConnectOptions setConnectTimeout(long timeout)

      Description copied from class: `RequestOptions`
      Sets the amount of time after which, if the request is not obtained from the client within the timeout period, the `Future<HttpClientRequest>` obtained from the client is failed with a `TimeoutException`. Note this is not related to the TCP `HttpClientOptions.setConnectTimeout(int)` option, when a request is made against a pooled HTTP client, the timeout applies to the duration to obtain a connection from the pool to serve the request, the timeout might fire because the server does not respond in time or the pool is too busy to serve a request.
      Overrides:
        `setConnectTimeout` in class `RequestOptions`
      Parameters:
        `timeout` - the amount of time in milliseconds.
      Returns:
        a reference to this, so the API can be used fluently

    - #### setIdleTimeout

          public WebSocketConnectOptions setIdleTimeout(long timeout)

      Sets the amount of time after which if the WebSocket handshake does not happen within the timeout period an `WebSocketHandshakeException` will be passed to the exception handler and the connection will be closed.
      Overrides:
        `setIdleTimeout` in class `RequestOptions`
      Parameters:
        `timeout` - the amount of time in milliseconds.
      Returns:
        a reference to this, so the API can be used fluently

    - #### addHeader

          public WebSocketConnectOptions addHeader(String key,
                                                   String value)

      Description copied from class: `RequestOptions`
      Add a request header.
      Overrides:
        `addHeader` in class `RequestOptions`
      Parameters:
        `key` - the header key
        `value` - the header value
      Returns:
        a reference to this, so the API can be used fluently

    - #### addHeader

          public WebSocketConnectOptions addHeader(CharSequence key,
                                                   CharSequence value)

      Description copied from class: `RequestOptions`
      Add a request header.
      Overrides:
        `addHeader` in class `RequestOptions`
      Parameters:
        `key` - the header key
        `value` - the header value
      Returns:
        a reference to this, so the API can be used fluently

    - #### addHeader

          public WebSocketConnectOptions addHeader(CharSequence key,
                                                   Iterable<CharSequence> values)

      Overrides:
        `addHeader` in class `RequestOptions`

    - #### putHeader

          public WebSocketConnectOptions putHeader(String key,
                                                   String value)

      Description copied from class: `RequestOptions`
      Set a request header.
      Overrides:
        `putHeader` in class `RequestOptions`
      Parameters:
        `key` - the header key
        `value` - the header value
      Returns:
        a reference to this, so the API can be used fluently

    - #### putHeader

          public WebSocketConnectOptions putHeader(CharSequence key,
                                                   CharSequence value)

      Description copied from class: `RequestOptions`
      Set a request header.
      Overrides:
        `putHeader` in class `RequestOptions`
      Parameters:
        `key` - the header key
        `value` - the header value
      Returns:
        a reference to this, so the API can be used fluently

    - #### putHeader

          public WebSocketConnectOptions putHeader(CharSequence key,
                                                   Iterable<CharSequence> values)

      Overrides:
        `putHeader` in class `RequestOptions`

    - #### setHeaders

          public WebSocketConnectOptions setHeaders(MultiMap headers)

      Description copied from class: `RequestOptions`
      Set request headers from a multi-map.
      Overrides:
        `setHeaders` in class `RequestOptions`
      Parameters:
        `headers` - the headers
      Returns:
        a reference to this, so the API can be used fluently

    - #### setServer

          public WebSocketConnectOptions setServer(SocketAddress server)

      Description copied from class: `RequestOptions`
      Set the server address to be used by the client request.

      When the server address is `null`, the address will be resolved after the `host` property by the Vert.x resolver.

      Use this when you want to connect to a specific server address without name resolution.

      Overrides:
        `setServer` in class `RequestOptions`
      Returns:
        a reference to this, so the API can be used fluently

    - #### setMethod

          public WebSocketConnectOptions setMethod(HttpMethod method)

      Description copied from class: `RequestOptions`
      Set the HTTP method to be used by the client request.
      Overrides:
        `setMethod` in class `RequestOptions`
      Returns:
        a reference to this, so the API can be used fluently

    - #### setFollowRedirects

          public WebSocketConnectOptions setFollowRedirects(Boolean followRedirects)

      Description copied from class: `RequestOptions`
      Set whether to follow HTTP redirect
      Overrides:
        `setFollowRedirects` in class `RequestOptions`
      Parameters:
        `followRedirects` - whether to follow redirect
      Returns:
        a reference to this, so the API can be used fluently

    - #### setAbsoluteURI

          public WebSocketConnectOptions setAbsoluteURI(String absoluteURI)

      Description copied from class: `RequestOptions`
      Parse an absolute URI to use, this will update the `ssl`, `host`, `port` and `uri` fields.
      Overrides:
        `setAbsoluteURI` in class `RequestOptions`
      Parameters:
        `absoluteURI` - the uri to use
      Returns:
        a reference to this, so the API can be used fluently

    - #### setAbsoluteURI

          public WebSocketConnectOptions setAbsoluteURI(URL url)

      Description copied from class: `RequestOptions`
      Like `RequestOptions.setAbsoluteURI(String)` but using an `URL` parameter.
      Overrides:
        `setAbsoluteURI` in class `RequestOptions`
      Parameters:
        `url` - the uri to use
      Returns:
        a reference to this, so the API can be used fluently

    - #### setTraceOperation

          public WebSocketConnectOptions setTraceOperation(String op)

      Description copied from class: `RequestOptions`
      Override the operation the tracer use for this request. When no operation is set, the HTTP method is used instead.
      Overrides:
        `setTraceOperation` in class `RequestOptions`
      Parameters:
        `op` - the override
      Returns:
        a reference to this, so the API can be used fluently

    - #### toJson

          public JsonObject toJson()

      Overrides:
        `toJson` in class `RequestOptions`

    - #### isRegisterWriteHandlers

          public boolean isRegisterWriteHandlers()

      Returns:
        `true` if write-handlers should be registered on the `EventBus`, otherwise `false`

    - #### setRegisterWriteHandlers

          public WebSocketConnectOptions setRegisterWriteHandlers(boolean registerWriteHandlers)

      Whether write-handlers should be registered on the `EventBus`.

      Defaults to `false`.

      Parameters:
        `registerWriteHandlers` - true to register write-handlers
      Returns:
        a reference to this, so the API can be used fluently
      See Also:
        `WebSocketBase.textHandlerID()`, `WebSocketBase.binaryHandlerID()`

Copyright © 2024 Eclipse. All rights reserved.