Class ClientProperties
- java.lang.Object
-
- org.glassfish.tyrus.client.ClientProperties
-
public final class ClientProperties extends java.lang.ObjectTyrus client configuration properties.- Author:
- Petr Janouch
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringAUTH_CONFIGAuthentication configuration.static java.lang.StringCREDENTIALSAuthentication credentials.static java.lang.StringHANDSHAKE_TIMEOUTProperty usable inClientManager.getProperties().static java.lang.StringINCOMING_BUFFER_SIZEProperty name for maximal incoming buffer size.static java.lang.StringLOG_HTTP_UPGRADEUser property to configure logging of HTTP upgrade messages.static java.lang.StringMASKING_KEY_GENERATORProperty name for registering a custom masking key generator.static java.lang.StringPROXY_HEADERSUser property to set additional proxy headers.static java.lang.StringPROXY_URIUser property to set proxy URI.static java.lang.StringRECONNECT_HANDLERProperty usable inClientManager.getProperties().static java.lang.StringREDIRECT_ENABLEDHTTP Redirect support.static java.lang.StringREDIRECT_THRESHOLDThe maximal number of redirects during single handshake.static java.lang.StringRETRY_AFTER_SERVICE_UNAVAILABLEHTTP Service Unavailable - "Retry-After" reconnect support.static java.lang.StringSHARED_CONTAINERWhen set totrue(boolean value), client runtime preserves used container and reuses it for outgoing connections.static java.lang.StringSHARED_CONTAINER_IDLE_TIMEOUTContainer idle timeout in seconds (Integervalue).static java.lang.StringSOCKET_BINDINGProperty name for defining local binding address for all socket created by the client.static java.lang.StringSSL_ENGINE_CONFIGURATORProperty usable inClientManager.getProperties()as a key for SSL configuration.static java.lang.StringWORKER_THREAD_POOL_CONFIGUser property to set worker thread pool configuration.
-
Constructor Summary
Constructors Constructor Description ClientProperties()
-
-
-
Field Detail
-
HANDSHAKE_TIMEOUT
public static final java.lang.String HANDSHAKE_TIMEOUT
Property usable inClientManager.getProperties().Value must be
intand represents handshake timeout in milliseconds. Default value is 30000 (30 seconds).- See Also:
- Constant Field Values
-
RECONNECT_HANDLER
public static final java.lang.String RECONNECT_HANDLER
Property usable inClientManager.getProperties().Value must be
ClientManager.ReconnectHandlerinstance.
-
PROXY_URI
public static final java.lang.String PROXY_URI
User property to set proxy URI.Value is expected to be
Stringand represent proxy URI. Protocol part is currently ignored but must be present (URI(String)is used for parsing).client.getProperties().put(ClientProperties.PROXY_URI, "http://my.proxy.com:80"); client.connectToServer(...);- See Also:
EndpointConfig.getUserProperties(), Constant Field Values
-
PROXY_HEADERS
public static final java.lang.String PROXY_HEADERS
User property to set additional proxy headers.Value is expected to be
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<String, String> proxyHeaders = new HashMap<String, String>(); proxyHeaders.put("Proxy-Authorization", "Basic " + Base64.getEncoder().encodeToString("username:password".getBytes(Charset.forName("UTF-8")))); 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, seeClientEndpointConfig.Configurator.beforeRequest(java.util.Map).- See Also:
EndpointConfig.getUserProperties(), Constant Field Values
-
SSL_ENGINE_CONFIGURATOR
public static final java.lang.String SSL_ENGINE_CONFIGURATOR
Property usable inClientManager.getProperties()as a key for SSL configuration.Value is expected to be either
org.glassfish.grizzly.ssl.SSLEngineConfiguratororSslEngineConfiguratorwhen configuring Grizzly client or onlySslEngineConfiguratorwhen configuring JDK client.The advantage of using
SslEngineConfiguratorwith Grizzly client is thatSslEngineConfiguratorallows 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);- See Also:
- Constant Field Values
-
INCOMING_BUFFER_SIZE
public static final java.lang.String INCOMING_BUFFER_SIZE
Property name for maximal incoming buffer size.Can be set in properties map (see
ClientContainer.openClientSocket(jakarta.websocket.ClientEndpointConfig, java.util.Map, org.glassfish.tyrus.spi.ClientEngine).- See Also:
- Constant Field Values
-
SHARED_CONTAINER
public static final java.lang.String SHARED_CONTAINER
When set totrue(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.
-
SHARED_CONTAINER_IDLE_TIMEOUT
public static final java.lang.String SHARED_CONTAINER_IDLE_TIMEOUT
Container idle timeout in seconds (Integervalue).When the timeout elapses, the shared thread pool will be destroyed.
- See Also:
SHARED_CONTAINER, Constant Field Values
-
WORKER_THREAD_POOL_CONFIG
public static final java.lang.String WORKER_THREAD_POOL_CONFIG
User property to set worker thread pool configuration.An instance of
ThreadPoolConfigis expected for both JDK and Grizzly client. Instance oforg.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());- See Also:
- Constant Field Values
-
AUTH_CONFIG
public static final java.lang.String AUTH_CONFIG
Authentication configuration. If no AuthConfig is specified then default configuration will be used, containing both Basic and Digest provided authenticators.Value must be
AuthConfiginstance.Sample below demonstrates how to use this property:
client.getProperties().put(ClientProperties.AUTH_CONFIG, AuthConfig.builder().enableProvidedBasicAuth() .build());- See Also:
AuthConfig,AuthConfig.Builder,Authenticator, Constant Field Values
-
CREDENTIALS
public static final java.lang.String CREDENTIALS
Authentication credentials.Value must be
Credentialsinstance.Provided authenticators (both Basic and Digest) require this property set, otherwise
AuthenticationExceptionwill 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");- See Also:
Credentials,AuthConfig,Authenticator, Constant Field Values
-
REDIRECT_ENABLED
public static final java.lang.String REDIRECT_ENABLED
HTTP Redirect support.Value is expected to be
boolean. Default value isfalse.When set to
trueand one of the following redirection HTTP response status code (3xx) is received during a handshake, client will attempt to connect to theURIcontained in "Location" header from handshake response. Number of redirection is limited by propertyREDIRECT_THRESHOLD(integer value), while default value is 5.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)
- See Also:
REDIRECT_THRESHOLD, Constant Field Values
-
REDIRECT_THRESHOLD
public static final java.lang.String REDIRECT_THRESHOLD
The maximal number of redirects during single handshake.Value is expected to be positive
Integer. Default value is 5.HTTP redirection must be enabled by property
REDIRECT_ENABLED, otherwiseREDIRECT_THRESHOLDis not applied.- See Also:
REDIRECT_ENABLED,RedirectException, Constant Field Values
-
RETRY_AFTER_SERVICE_UNAVAILABLE
public static final java.lang.String RETRY_AFTER_SERVICE_UNAVAILABLE
HTTP Service Unavailable - "Retry-After" reconnect support.Value is expected to be
boolean. Default value isfalse.When set to
trueand HTTP response code503 - Service Unavailableis received, client will attempt to reconnect after delay specified in "Retry-After" header from handshake response. According to RFC 2616 the value must be decimal integer (representing delay in seconds) orhttp-date.Tyrus client will try to reconnect after this delay if:
- "Retry-After" header is present and is not empty
- "Retry-After" header can be parsed
- number of reconnection attempts does not exceed 5
- delay is not longer then 300 seconds
-
LOG_HTTP_UPGRADE
public static final java.lang.String LOG_HTTP_UPGRADE
User property to configure logging of HTTP upgrade messages.Value is expected to be
boolean. Default value isfalse.When set to
trueupgrade request and response messages will be logged regardless of the logging level configuration. When the logging is configured toLevel.FINEor lower, this setting will have no effect as at this level HTTP upgrade messages will be logged anyway.- See Also:
- Constant Field Values
-
MASKING_KEY_GENERATOR
public static final java.lang.String MASKING_KEY_GENERATOR
Property name for registering a custom masking key generator. The expected value is an instance ofMaskingKeyGenerator.As a security measure, all frames originating on websocket client have to be masked with random 4B value, which should be freshly generated for each frame. Moreover to fully comply with the security requirements of RFC 6455, a masking key of a frame must not be predictable from masking keys of previous frames and therefore Tyrus uses
SecureRandomas a default masking key generator. While this is perfectly OK for most Tyrus client use cases, usage ofSecureRandommight prove to be a performance issue, when the client is used for instance for highly parallel stress testing asSecureRandomuses a synchronized singleton as a random entropy provider in its internals.This property allows replacing the default
SecureRandomwith a more scalable provider of masking keys.- See Also:
- Constant Field Values
-
SOCKET_BINDING
public static final java.lang.String SOCKET_BINDING
Property name for defining local binding address for all socket created by the client. The expected value is an instance ofInetAddress.Sample below demonstrates how to use this property:
client.getProperties().put(ClientProperties.SOCKET_BINDING, InetAddress.getByName("127.0.0.1"));- See Also:
- Constant Field Values
-
-