| Constructor and Description |
|---|
WebSocketFactory()
Constructor.
|
WebSocketFactory(WebSocketFactory other)
Copy constructor.
|
| Modifier and Type | Method and Description |
|---|---|
WebSocket |
createSocket(String uri)
Create a WebSocket.
|
WebSocket |
createSocket(String uri,
int timeout)
Create a WebSocket.
|
WebSocket |
createSocket(URI uri)
Create a WebSocket.
|
WebSocket |
createSocket(URI uri,
int timeout)
Create a WebSocket.
|
WebSocket |
createSocket(URL url)
Create a WebSocket.
|
WebSocket |
createSocket(URL url,
int timeout)
Create a WebSocket.
|
int |
getConnectionTimeout()
Get the timeout value in milliseconds for socket connection.
|
int |
getDualStackFallbackDelay()
Get the dual stack fallback delay in milliseconds that will be applied
when establishing a socket connection.
|
DualStackMode |
getDualStackMode()
Get the dual stack mode that will be applied when establishing a socket
connection.
|
ProxySettings |
getProxySettings()
Get the proxy settings.
|
String[] |
getServerNames()
Get server names for SNI (Server Name Indication).
|
SocketFactory |
getSocketFactory()
Get the socket factory that has been set by
setSocketFactory(SocketFactory). |
int |
getSocketTimeout()
Get the timeout value in milliseconds for socket read and write operations.
|
SSLContext |
getSSLContext()
Get the SSL context that has been set by
setSSLContext(SSLContext). |
SSLSocketFactory |
getSSLSocketFactory()
Get the SSL socket factory that has been set by
setSSLSocketFactory(SSLSocketFactory). |
boolean |
getVerifyHostname()
Get the flag which indicates whether the hostname in the
server's certificate should be verified or not.
|
WebSocketFactory |
setConnectionTimeout(int timeout)
Set the timeout value in milliseconds for socket connection.
|
WebSocketFactory |
setDualStackFallbackDelay(int delay)
Set the dual stack fallback delay in milliseconds that will be applied
when establishing a socket connection.
|
WebSocketFactory |
setDualStackMode(DualStackMode mode)
Set the dual stack mode that will be applied when establishing a socket
connection.
|
WebSocketFactory |
setServerName(String serverName)
Set a server name for SNI (Server Name Indication).
|
WebSocketFactory |
setServerNames(String[] serverNames)
Set server names for SNI (Server Name Indication).
|
WebSocketFactory |
setSocketFactory(SocketFactory factory)
Set a socket factory.
|
WebSocketFactory |
setSocketTimeout(int timeout)
Set the timeout value in milliseconds for socket read and write operations.
|
WebSocketFactory |
setSSLContext(SSLContext context)
Set an SSL context to get a socket factory.
|
WebSocketFactory |
setSSLSocketFactory(SSLSocketFactory factory)
Set an SSL socket factory.
|
WebSocketFactory |
setVerifyHostname(boolean verifyHostname)
Set the flag which indicates whether the hostname in the
server's certificate should be verified or not.
|
public WebSocketFactory()
public WebSocketFactory(WebSocketFactory other)
other - A WebSocketFactory instance to copy.IllegalArgumentException - If the given WebSocketFactory instance is null.public SocketFactory getSocketFactory()
setSocketFactory(SocketFactory).public WebSocketFactory setSocketFactory(SocketFactory factory)
createSocket(URI) for details.factory - A socket factory.this instance.public SSLSocketFactory getSSLSocketFactory()
setSSLSocketFactory(SSLSocketFactory).public WebSocketFactory setSSLSocketFactory(SSLSocketFactory factory)
createSocket(URI) for details.factory - An SSL socket factory.this instance.public SSLContext getSSLContext()
setSSLContext(SSLContext).public WebSocketFactory setSSLContext(SSLContext context)
createSocket(URI) for details.context - An SSL context.this instance.public ProxySettings getProxySettings()
ProxySettingspublic int getConnectionTimeout()
When a createSocket method which does not have timeout argument is called, the value returned by this method
is used as a timeout value for socket connection.
public WebSocketFactory setConnectionTimeout(int timeout)
timeout - The connection timeout value in milliseconds.this object.IllegalArgumentException - The given timeout value is negative.public int getSocketTimeout()
This can be changed later with getSocket().setSoTimeout(int).
Socket.setSoTimeout(int)public WebSocketFactory setSocketTimeout(int timeout)
This can be changed later with getSocket().setSoTimeout(int).
timeout - The socket timeout value in milliseconds.this object.IllegalArgumentException - The given timeout value is negative.Socket.setSoTimeout(int)public DualStackMode getDualStackMode()
DualStackMode.BOTH.
A hostname may resolve to an arbitrary amount of IPv4 and IPv6 addresses. This controls which IP address families will be used when establishing a connection. Note that IPv6 will be preferred, if activated.
public WebSocketFactory setDualStackMode(DualStackMode mode)
mode - The dual stack mode to be applied.this object.public int getDualStackFallbackDelay()
A hostname may resolve to an arbitrary amount of IPv4 and IPv6 addresses. This controls the maximum amount of time that may pass between attempts to establish a socket connection to an IP addresses before trying the next one. Note that the previous attempt will not be aborted. The connections will race until one has been established.
public WebSocketFactory setDualStackFallbackDelay(int delay)
delay - The dual stack fallback delay in milliseconds.this object.public boolean getVerifyHostname()
true. See the description of setVerifyHostname(boolean) to understand what this boolean
flag means.true if hostname verification is enabled.public WebSocketFactory setVerifyHostname(boolean verifyHostname)
true.
Manual hostname verification has been enabled since the version
2.1. Because the verification is executed manually after Socket.connect(SocketAddress, int)
succeeds, the hostname verification is always executed even if
you has passed an SSLContext which naively accepts any
server certificate (e.g. NaiveSSLContext). However, this behavior is not
desirable in some cases and you may want to disable the hostname
verification. This setter method exists for the purpose and you
can disable hostname verification by passing false to
this method.
verifyHostname - true to enable hostname verification.
false to disable hostname verification.this object.public String[] getServerNames()
public WebSocketFactory setServerNames(String[] serverNames)
setServerNames(List<SNIServerName>) method of
SSLParameters class is available
in the underlying system, the method is called to set up server names
for SNI (Server Name Indication).serverNames - List of host names.this object.public WebSocketFactory setServerName(String serverName)
serverName and calls setServerNames(String[]).serverName - A host name.this object.public WebSocket createSocket(String uri) throws IOException
This method is an alias of createSocket(uri, getConnectionTimeout()).
uri - The URI of the WebSocket endpoint on the server side.IllegalArgumentException - The given URI is null or violates RFC 2396.IOException - Failed to create a socket. Or, HTTP proxy handshake or SSL
handshake failed.public WebSocket createSocket(String uri, int timeout) throws IOException
This method is an alias of createSocket(URI.create(uri), timeout).
uri - The URI of the WebSocket endpoint on the server side.timeout - The timeout value in milliseconds for socket connection.
A timeout of zero is interpreted as an infinite timeout.IllegalArgumentException - The given URI is null or violates RFC 2396, or
the given timeout value is negative.IOException - Failed to create a socket. Or, HTTP proxy handshake or SSL
handshake failed.public WebSocket createSocket(URL url) throws IOException
This method is an alias of createSocket(url, getConnectionTimeout()).
url - The URL of the WebSocket endpoint on the server side.IllegalArgumentException - The given URL is null or failed to be converted into a URI.IOException - Failed to create a socket. Or, HTTP proxy handshake or SSL
handshake failed.public WebSocket createSocket(URL url, int timeout) throws IOException
This method is an alias of createSocket(url.toURI(), timeout).
url - The URL of the WebSocket endpoint on the server side.timeout - The timeout value in milliseconds for socket connection.IllegalArgumentException - The given URL is null or failed to be converted into a URI,
or the given timeout value is negative.IOException - Failed to create a socket. Or, HTTP proxy handshake or SSL
handshake failed.public WebSocket createSocket(URI uri) throws IOException
createSocket(uri, getConnectionTimeout()).
A socket factory (= a SocketFactory instance) to create a raw
socket (= a Socket instance) is determined as described below.
wss or https,
SSLContext instance has been set by setSSLContext(SSLContext), the value returned from SSLContext.getSocketFactory() method of the instance is used.
SSLSocketFactory instance has been
set by setSSLSocketFactory(SSLSocketFactory), the
instance is used.
SSLSocketFactory.getDefault()
is used.
ws or http),
SocketFactory instance has been set by setSocketFactory(SocketFactory), the instance is used.
SocketFactory.getDefault()
is used.
uri - The URI of the WebSocket endpoint on the server side.
The scheme part of the URI must be one of ws,
wss, http and https
(case-insensitive).IllegalArgumentException - The given URI is null or violates RFC 2396.IOException - Failed to create a socket.public WebSocket createSocket(URI uri, int timeout) throws IOException
A socket factory (= a SocketFactory instance) to create a raw
socket (= a Socket instance) is determined as described below.
wss or https,
SSLContext instance has been set by setSSLContext(SSLContext), the value returned from SSLContext.getSocketFactory() method of the instance is used.
SSLSocketFactory instance has been
set by setSSLSocketFactory(SSLSocketFactory), the
instance is used.
SSLSocketFactory.getDefault()
is used.
ws or http),
SocketFactory instance has been set by setSocketFactory(SocketFactory), the instance is used.
SocketFactory.getDefault()
is used.
uri - The URI of the WebSocket endpoint on the server side.
The scheme part of the URI must be one of ws,
wss, http and https
(case-insensitive).timeout - The timeout value in milliseconds for socket connection.IllegalArgumentException - The given URI is null or violates RFC 2396, or
the given timeout value is negative.IOException - Failed to create a socket.Copyright © 2021. All rights reserved.