T - The concrete builder class.public abstract static class ConnectionConfiguration.Builder<T extends ConnectionConfiguration.Builder<T>> extends Object
| Modifier and Type | Method and Description |
|---|---|
abstract ConnectionConfiguration |
build()
Builds the connection configuration.
|
T |
compressionMethods(CompressionMethod... compressionMethods)
Sets the compression method.
|
T |
connectTimeout(int connectTimeout)
Sets a timeout for the connection establishment.
|
T |
hostname(String hostname)
Sets the hostname.
|
T |
hostnameVerifier(HostnameVerifier hostnameVerifier)
Sets an optional hostname verifier, used to verify the hostname in the certificate presented by the server.
|
T |
port(int port)
Sets the port.
|
T |
proxy(Proxy proxy)
Sets the proxy, e.g. if you are behind a HTTP proxy and use a BOSH connection.
|
T |
secure(boolean secure)
Sets whether the connection is secured via SSL.
|
T |
sslContext(SSLContext sslContext)
Sets a custom SSL context, used to secure the connection.
|
public final T hostname(String hostname)
hostname - The hostname.public final T port(int port)
port - The port.public final T proxy(Proxy proxy)
proxy - The proxy.public final T secure(boolean secure)
A standard TCP connection starts with a plain socket and negotiates a secure SSL connection during stream negotiation via 'StartTLS'.
Hence, setting secure(true) means, you start with a plain socket and upgrade it to a secure socket during XMPP negotiation.
Setting secure(false) 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 set a custom SSL socket factory.
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 secure(true) for these connection methods means the connection connects via https or wss respectively.
If you set this to true, you should also set an SSLContext. Otherwise SSLContext.getDefault() is used.
secure - If the connection is secured via SSL.sslContext(SSLContext)public final T sslContext(SSLContext sslContext)
secure(true).sslContext - The SSL context.secure(boolean)public final T hostnameVerifier(HostnameVerifier hostnameVerifier)
hostnameVerifier - The hostname verifier.public final T connectTimeout(int connectTimeout)
Connecting to a XMPP server involves multiple steps:
XMPP stream negotiation is configured via XmppSessionConfiguration.Builder.defaultResponseTimeout(java.time.Duration)
connectTimeout - The timeout in milliseconds.IllegalArgumentException - If the timeout is negative.XmppSession.connect()public final T compressionMethods(CompressionMethod... compressionMethods)
compressionMethods - The compression methods.CompressionMethod.ZLIB,
CompressionMethod.GZIP,
CompressionMethod.DEFLATEpublic abstract ConnectionConfiguration build()
Copyright © 2014–2018 XMPP.rocks. All rights reserved.