public class WebSocketTransportRegistration extends Object
| Constructor and Description |
|---|
WebSocketTransportRegistration() |
| Modifier and Type | Method and Description |
|---|---|
WebSocketTransportRegistration |
addDecoratorFactory(org.springframework.web.socket.handler.WebSocketHandlerDecoratorFactory factory)
Add a factory that to decorate the handler used to process WebSocket messages.
|
protected List<org.springframework.web.socket.handler.WebSocketHandlerDecoratorFactory> |
getDecoratorFactories() |
protected Integer |
getSendBufferSizeLimit()
Protected accessor for internal use.
|
protected Integer |
getSendTimeLimit()
Protected accessor for internal use.
|
WebSocketTransportRegistration |
setDecoratorFactories(org.springframework.web.socket.handler.WebSocketHandlerDecoratorFactory... factories)
Configure one or more factories to decorate the handler used to process WebSocket
messages.
|
WebSocketTransportRegistration |
setSendBufferSizeLimit(int sendBufferSizeLimit)
Configure the maximum amount of data to buffer when sending messages to a WebSocket
session, or an HTTP response when SockJS fallback option are in use.
|
WebSocketTransportRegistration |
setSendTimeLimit(int timeLimit)
Configure a time limit (in milliseconds) for the maximum amount of a time allowed
when sending messages to a WebSocket session or writing to an HTTP response when
SockJS fallback option are in use.
|
public WebSocketTransportRegistration setSendTimeLimit(int timeLimit)
In general WebSocket servers expect that messages to a single WebSocket session are
sent from a single thread at a time. This is automatically guaranteed when using
@EnableWebSocketMessageBroker configuration. If message sending is slow, or
at least slower than rate of messages sending, subsequent messages are buffered
until either the sendTimeLimit or the sendBufferSizeLimit are
reached at which point the session state is cleared and an attempt is made to close
the session.
NOTE that the session time limit is checked only on attempts to send additional messages. So if only a single message is sent and it hangs, the session will not time out until another message is sent or the underlying physical socket times out. So this is not a replacement for WebSocket server or HTTP connection timeout but is rather intended to control the extent of buffering of unsent messages.
NOTE that closing the session may not succeed in actually closing
the physical socket and may also hang. This is true especially when using blocking
IO such as the BIO connector in Tomcat that is used by default on Tomcat 7.
Therefore it is recommended to ensure the server is using non-blocking IO such as
Tomcat's NIO connector that is used by default on Tomcat 8. If you must use
blocking IO consider customizing OS-level TCP settings, for example
/proc/sys/net/ipv4/tcp_retries2 on Linux.
The default value is 10 seconds (i.e. 10 * 10000).
timeLimit - the timeout value in milliseconds; the value must be greater than
0, otherwise it is ignored.protected Integer getSendTimeLimit()
public WebSocketTransportRegistration setSendBufferSizeLimit(int sendBufferSizeLimit)
In general WebSocket servers expect that messages to a single WebSocket session are
sent from a single thread at a time. This is automatically guaranteed when using
@EnableWebSocketMessageBroker configuration. If message sending is slow, or
at least slower than rate of messages sending, subsequent messages are buffered
until either the sendTimeLimit or the sendBufferSizeLimit are
reached at which point the session state is cleared and an attempt is made to close
the session.
NOTE that closing the session may not succeed in actually closing
the physical socket and may also hang. This is true especially when using blocking
IO such as the BIO connector in Tomcat configured by default on Tomcat 7. Therefore
it is recommended to ensure the server is using non-blocking IO such as Tomcat's
NIO connector used by default on Tomcat 8. If you must use blocking IO consider
customizing OS-level TCP settings, for example
/proc/sys/net/ipv4/tcp_retries2 on Linux.
The default value is 512K (i.e. 512 * 1024).
sendBufferSizeLimit - the maximum number of bytes to buffer when sending
messages; if the value is less than or equal to 0 then buffering is effectively
disabled.protected Integer getSendBufferSizeLimit()
public WebSocketTransportRegistration setDecoratorFactories(org.springframework.web.socket.handler.WebSocketHandlerDecoratorFactory... factories)
public WebSocketTransportRegistration addDecoratorFactory(org.springframework.web.socket.handler.WebSocketHandlerDecoratorFactory factory)
protected List<org.springframework.web.socket.handler.WebSocketHandlerDecoratorFactory> getDecoratorFactories()
Copyright © 2014–2017. All rights reserved.