Class ClientConnectionConfiguration.Builder<T extends ClientConnectionConfiguration.Builder<T,​C>,​C extends ClientConnectionConfiguration>

    • Method Detail

      • hostname

        public final T hostname​(String hostname)
        Sets the hostname.
        Parameters:
        hostname - The hostname.
        Returns:
        The builder.
      • port

        public final T port​(int port)
        Sets the port.
        Parameters:
        port - The port.
        Returns:
        The builder.
      • proxy

        public final T proxy​(Proxy proxy)
        Sets the proxy, e.g. if you are behind a HTTP proxy and use a BOSH connection.
        Parameters:
        proxy - The proxy.
        Returns:
        The builder.
      • channelEncryption

        public final T channelEncryption​(ChannelEncryption channelEncryption)
        Sets how the connection is secured via SSL.

        A standard TCP connection starts with a plain socket and negotiates a secure SSL connection during stream negotiation via 'StartTLS'. Hence, setting ChannelEncryption.OPTIONAL means, you start with a plain socket and upgrade it to a secure socket during XMPP negotiation, if possible.

        Setting ChannelEncryption.DISABLED means, you start with plain socket and won't upgrade to a secure socket. However, some servers require that the client secures the connection, in which case an exception is thrown during connecting.

        If your server expects the connection to be secured immediately (often on port 5223), you should use ChannelEncryption.DIRECT.

        See RFC 6120 ยง 5. STARTTLS Negotiation for further information.

        HTTP (BOSH) and WebSocket connections provide TLS outside of the XMPP layer, i.e. it's not negotiated in XMPP. Setting ChannelEncryption.DIRECT for these connection methods means the connection connects via https or wss respectively. ChannelEncryption.OPTIONAL and ChannelEncryption.REQUIRED are not applicable for these connecion methods.

        If you set this to true, you should also set an SSLContext. Otherwise SSLContext.getDefault() is used.

        Parameters:
        channelEncryption - The channel encryption mode.
        Returns:
        The builder.
        See Also:
        sslContext(SSLContext)
      • sslContext

        public final T sslContext​(SSLContext sslContext)
        Sets a custom SSL context, used to secure the connection. This SSL context only takes effect, when setting secure(true).
        Parameters:
        sslContext - The SSL context.
        Returns:
        The builder.
        See Also:
        channelEncryption(ChannelEncryption)
      • hostnameVerifier

        public final T hostnameVerifier​(HostnameVerifier hostnameVerifier)
        Sets an optional hostname verifier, used to verify the hostname in the certificate presented by the server. If no verifier is set, the hostname is verified nonetheless using the default.
        Parameters:
        hostnameVerifier - The hostname verifier.
        Returns:
        The builder.
      • connectTimeout

        public final T connectTimeout​(int connectTimeout)
        Sets a timeout for the connection establishment.

        Connecting to a XMPP server involves multiple steps:

        • DNS lookup
        • Connection establishment of the underlying transport (e.g. TCP or HTTP)
        • XMPP stream negotiation

        This timeout is only used for DNS lookup (which is not used in all cases) and for connection establishment of the underlying transport (e.g. for a socket connection), but not for stream negotiation. Therefore it does not reflect how long the whole connection process may take, but should be understood as hint for establishing the underlying XMPP transport.

        XMPP stream negotiation is configured via XmppSessionConfiguration.Builder.defaultResponseTimeout(java.time.Duration)

        Parameters:
        connectTimeout - The timeout in milliseconds.
        Returns:
        The builder.
        Throws:
        IllegalArgumentException - If the timeout is negative.
        See Also:
        XmppSession.connect()
      • connector

        public final T connector​(TransportConnector<C> connector)
        Sets the transport connector, which is used to establish a connection.
        Parameters:
        connector - The transport connector.
        Returns:
        The builder.
      • build

        public abstract ClientConnectionConfiguration build()
        Builds the connection configuration.
        Returns:
        The concrete connection configuration.
      • getConnector

        public TransportConnector<C> getConnector()
        Gets the transport connector.
        Returns:
        The transport connector.