Class HttpClientWebSocketConnector

  • All Implemented Interfaces:
    TransportConnector<WebSocketConnectionConfiguration>

    public final class HttpClientWebSocketConnector
    extends Object
    A WebSocket transport connector which uses WebSocket.

    This is the default connector for WebSocket based XMPP connections if none is defined.

    However, you could still explicitly set it as shown below.

    Sample Usage

    
     WebSocketConnectionConfiguration webSocketConfiguration = WebSocketConnectionConfiguration.builder()
         .hostname("localhost")
         .port(443)
         .sslContext(sslContext)
         .channelEncryption(ChannelEncryption.DIRECT)
         .connector(new HttpClientWebSocketConnector())
         .build();
     

    Hostname Verification

    Please note that the WebSocket API does not allow to set a hostname verifier. To disable hostname verification you have to set the system property:

    -Djdk.internal.httpclient.disableHostnameVerification
    See Also:
    ClientConnectionConfiguration.Builder.connector(TransportConnector)
    • Constructor Detail

      • HttpClientWebSocketConnector

        public HttpClientWebSocketConnector()
    • Method Detail

      • connect

        public final CompletableFuture<Connection> connect​(XmppSession xmppSession,
                                                           WebSocketConnectionConfiguration configuration,
                                                           SessionOpen sessionOpen)
        Description copied from interface: TransportConnector
        Establishes a connection using the transport protocol specific configuration.
        Parameters:
        xmppSession - The XMPP session which will be bound to the transport protocol.
        configuration - The connection configuration for the specific transport protocol.
        sessionOpen - The session open element.
        Returns:
        A CompletableFuture which returns an established (connected) connection on completion.