public final class ClientProperties extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
AUTH_CONFIG
Authentication configuration.
|
static String |
CREDENTIALS
Authentication credentials.
|
static String |
HANDSHAKE_TIMEOUT
Property usable in
ClientManager.getProperties(). |
static String |
INCOMING_BUFFER_SIZE
Property name for maximal incoming buffer size.
|
static String |
LOG_HTTP_UPGRADE
User property to configure logging of HTTP upgrade messages.
|
static String |
PROXY_HEADERS
User property to set additional proxy headers.
|
static String |
PROXY_URI
User property to set proxy URI.
|
static String |
RECONNECT_HANDLER
Property usable in
ClientManager.getProperties(). |
static String |
REDIRECT_ENABLED
HTTP Redirect support.
|
static String |
REDIRECT_THRESHOLD
The maximal number of redirects during single handshake.
|
static String |
RETRY_AFTER_SERVICE_UNAVAILABLE
HTTP Service Unavailable - reconnect support.
|
static String |
SHARED_CONTAINER
When set to
true (boolean value), client runtime preserves used container and reuses it for outgoing
connections. |
static String |
SHARED_CONTAINER_IDLE_TIMEOUT
Container idle timeout in seconds (
Integer value). |
static String |
SSL_ENGINE_CONFIGURATOR
Property usable in
ClientManager.getProperties() as a key for SSL configuration. |
static String |
WORKER_THREAD_POOL_CONFIG
User property to set worker thread pool configuration.
|
| Constructor and Description |
|---|
ClientProperties() |
public static final String HANDSHAKE_TIMEOUT
ClientManager.getProperties().
Value must be int and represents handshake timeout in milliseconds. Default value is 30000 (30 seconds).public static final String RECONNECT_HANDLER
ClientManager.getProperties().
Value must be ClientManager.ReconnectHandler instance.
public static final String PROXY_URI
String and represent proxy URI. Protocol part is currently ignored
but must be present (URI.URI(String) is used for parsing).
client.getProperties().put(ClientProperties.PROXY_URI, "http://my.proxy.com:80");
client.connectToServer(...);
public static final String PROXY_HEADERS
Map<String, String> and represent raw http headers
to be added to initial request which is sent to proxy. Key corresponds to header name, value is header
value.
Sample below demonstrates use of this feature to set preemptive basic proxy authentication:
final HashMap proxyHeaders = new HashMap();
proxyHeaders.put("Proxy-Authorization", "Basic " + Base64Utils.encodeToString("username:password".getBytes(Charset.forName("UTF-8")), false));
client.getProperties().put(ClientProperties.PROXY_HEADERS, proxyHeaders);
client.connectToServer(...);
Please note that these headers will be used only when establishing proxy connection, for modifying
WebSocket handshake headers, see ClientEndpointConfig.Configurator.beforeRequest(java.util.Map).public static final String SSL_ENGINE_CONFIGURATOR
ClientManager.getProperties() as a key for SSL configuration.
Value is expected to be either org.glassfish.grizzly.ssl.SSLEngineConfigurator or
SslEngineConfigurator when configuring Grizzly client or only
SslEngineConfigurator when configuring JDK client.
The advantage of using SslEngineConfigurator with Grizzly client is that
SslEngineConfigurator allows configuration of host name verification
(which is turned on by default)
Example configuration for JDK client:
SslContextConfigurator sslContextConfigurator = new SslContextConfigurator();
sslContextConfigurator.setTrustStoreFile("...");
sslContextConfigurator.setTrustStorePassword("...");
sslContextConfigurator.setTrustStoreType("...");
sslContextConfigurator.setKeyStoreFile("...");
sslContextConfigurator.setKeyStorePassword("...");
sslContextConfigurator.setKeyStoreType("...");
SslEngineConfigurator sslEngineConfigurator = new SslEngineConfigurator(sslContextConfigurator, true, false, false);
client.getProperties().put(ClientProperties.SSL_ENGINE_CONFIGURATOR, sslEngineConfigurator);
public static final String INCOMING_BUFFER_SIZE
ClientContainer.openClientSocket(ClientEndpointConfig, Map, ClientEngine)).public static final String SHARED_CONTAINER
true (boolean value), client runtime preserves used container and reuses it for outgoing
connections.
A single thread pool is reused by all clients with this property set to true.
JDK client supports only shared container option, so setting this property has no effect.public static final String SHARED_CONTAINER_IDLE_TIMEOUT
Integer value).
When the timeout elapses, the shared thread pool will be destroyed.SHARED_CONTAINER,
Constant Field Valuespublic static final String WORKER_THREAD_POOL_CONFIG
ThreadPoolConfig is expected for both JDK
and Grizzly client. Instance of org.glassfish.grizzly.threadpool.ThreadPoolConfig, can be used
for Grizzly client.
Sample below demonstrates how to use this property:
client.getProperties().put(ClientProperties.WORKER_THREAD_POOL_CONFIG, ThreadPoolConfig.defaultConfig());
public static final String AUTH_CONFIG
AuthConfig instance.
Sample below demonstrates how to use this property:
client.getProperties().put(ClientProperties.AUTH_CONFIG, AuthConfig.builder().enableProvidedBasicAuth().build());
AuthConfig,
AuthConfig.Builder,
Authenticator,
Constant Field Valuespublic static final String CREDENTIALS
Credentials instance.
Provided authenticators (both Basic and Digest) require this property set,
otherwise AuthenticationException will be thrown during a handshake.
User defined authenticators may look up credentials in another sources.
Sample below demonstrates how to use this property:
client.getProperties().put(ClientProperties.CREDENTIALS, new Credentials("websocket_user", "password");
Credentials,
AuthConfig,
Authenticator,
Constant Field Valuespublic static final String REDIRECT_ENABLED
boolean. Default value is false.
When set to true and one of the following redirection HTTP response status code (3xx) is received
during a handshake, client will attempt to connect to the URI contained in
header from handshake response. Number of redirection is limited by property
REDIRECT_THRESHOLD (integer value), while default value is .
List of supported HTTP status codes:
300 - Multiple Choices301 - Moved permanently302 - Found303 - See Other (since HTTP/1.1)307 - Temporary Redirect (since HTTP/1.1)308 - Permanent Redirect (Experimental RFC; RFC 7238)REDIRECT_THRESHOLD,
Constant Field Valuespublic static final String REDIRECT_THRESHOLD
Integer. Default value is .
HTTP redirection must be enabled by property REDIRECT_ENABLED, otherwise REDIRECT_THRESHOLD is not applied.public static final String RETRY_AFTER_SERVICE_UNAVAILABLE
boolean. Default value is false.
When set to true and HTTP response code 503 - Service Unavailable is received, client will attempt
to reconnect after delay specified in header from handshake response. According to
RFC 2616 the value must be decimal integer (representing delay in seconds) or http-date.
Tyrus client will try to reconnect after this delay if:
public static final String LOG_HTTP_UPGRADE
boolean. Default value is false.
When set to true upgrade request and response messages will be logged regardless of the logging
level configuration. When the logging is configured to Level.FINE or lower,
this setting will have no effect as at this level HTTP upgrade messages will be logged anyway.Copyright © 2012-2014, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.