org.springframework.web.socket.config.annotation

## Class SockJsServiceRegistration

- java.lang.Object
- - org.springframework.web.socket.config.annotation.SockJsServiceRegistration

-     public class SockJsServiceRegistration
      extends Object

  A helper class for configuring SockJS fallback options, typically used indirectly, in conjunction with `@EnableWebSocket` and `WebSocketConfigurer`.
  Since:
    4.0
  Author:
    Rossen Stoyanchev

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `SockJsServiceRegistration(TaskScheduler defaultTaskScheduler)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected SockJsService` | `getSockJsService()`
    `SockJsServiceRegistration` | `setClientLibraryUrl(String clientLibraryUrl)` Transports which don't support cross-domain communication natively (e.g.
    `SockJsServiceRegistration` | `setDisconnectDelay(long disconnectDelay)` The amount of time in milliseconds before a client is considered disconnected after not having a receiving connection, i.e.
    `SockJsServiceRegistration` | `setHeartbeatTime(long heartbeatTime)` The amount of time in milliseconds when the server has not sent any messages and after which the server should send a heartbeat frame to the client in order to keep the connection from breaking.
    `SockJsServiceRegistration` | `setHttpMessageCacheSize(int httpMessageCacheSize)` The number of server-to-client messages that a session can cache while waiting for the next HTTP polling request from the client.
    `SockJsServiceRegistration` | `setInterceptors(HandshakeInterceptor... interceptors)`
    `SockJsServiceRegistration` | `setSessionCookieNeeded(boolean sessionCookieNeeded)` The SockJS protocol requires a server to respond to the initial "/info" request from clients with a "cookie_needed" boolean property that indicates whether the use of a JSESSIONID cookie is required for the application to function correctly, e.g.
    `SockJsServiceRegistration` | `setStreamBytesLimit(int streamBytesLimit)` Streaming transports save responses on the client side and don't free memory used by delivered messages.
    `SockJsServiceRegistration` | `setTaskScheduler(TaskScheduler taskScheduler)`
    `SockJsServiceRegistration` | `setTransportHandlerOverrides(TransportHandler... handlers)`
    `SockJsServiceRegistration` | `setTransportHandlers(TransportHandler... handlers)`
    `SockJsServiceRegistration` | `setWebSocketEnabled(boolean webSocketEnabled)` Some load balancers don't support WebSocket.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### SockJsServiceRegistration

          public SockJsServiceRegistration(TaskScheduler defaultTaskScheduler)

  - ### Method Detail

    - #### setTaskScheduler

          public SockJsServiceRegistration setTaskScheduler(TaskScheduler taskScheduler)

    - #### setClientLibraryUrl

          public SockJsServiceRegistration setClientLibraryUrl(String clientLibraryUrl)

      Transports which don't support cross-domain communication natively (e.g. "eventsource", "htmlfile") rely on serving a simple page (using the "foreign" domain) from an invisible iframe. Code run from this iframe doesn't need to worry about cross-domain issues since it is running from a domain local to the SockJS server. The iframe does need to load the SockJS javascript client library and this option allows configuring its url. See the reference documentation for more details on this.

      By default this is set to point to "https://d1fxtkz8shb9d2.cloudfront.net/sockjs-0.3.4.min.js".

    - #### setStreamBytesLimit

          public SockJsServiceRegistration setStreamBytesLimit(int streamBytesLimit)

      Streaming transports save responses on the client side and don't free memory used by delivered messages. Such transports need to recycle the connection once in a while. This property sets a minimum number of bytes that can be send over a single HTTP streaming request before it will be closed. After that client will open a new request. Setting this value to one effectively disables streaming and will make streaming transports to behave like polling transports.

      The default value is 128K (i.e. 128 * 1024).

    - #### setSessionCookieNeeded

          public SockJsServiceRegistration setSessionCookieNeeded(boolean sessionCookieNeeded)

      The SockJS protocol requires a server to respond to the initial "/info" request from clients with a "cookie_needed" boolean property that indicates whether the use of a JSESSIONID cookie is required for the application to function correctly, e.g. for load balancing or in Java Servlet containers for the use of an HTTP session.

      This is especially important for IE 8,9 that support XDomainRequest -- a modified AJAX/XHR -- that can do requests across domains but does not send any cookies. In those cases, the SockJS client prefers the "iframe-htmlfile" transport over "xdr-streaming" in order to be able to send cookies.

      The default value is "true" to maximize the chance for applications to work correctly in IE 8,9 with support for cookies (and the JSESSIONID cookie in particular). However, an application can choose to set this to "false" if the use of cookies (and HTTP session) is not required.

    - #### setHeartbeatTime

          public SockJsServiceRegistration setHeartbeatTime(long heartbeatTime)

      The amount of time in milliseconds when the server has not sent any messages and after which the server should send a heartbeat frame to the client in order to keep the connection from breaking.

      The default value is 25,000 (25 seconds).

    - #### setDisconnectDelay

          public SockJsServiceRegistration setDisconnectDelay(long disconnectDelay)

      The amount of time in milliseconds before a client is considered disconnected after not having a receiving connection, i.e. an active connection over which the server can send data to the client.

      The default value is 5000.

    - #### setHttpMessageCacheSize

          public SockJsServiceRegistration setHttpMessageCacheSize(int httpMessageCacheSize)

      The number of server-to-client messages that a session can cache while waiting for the next HTTP polling request from the client. All HTTP transports use this property since even streaming transports recycle HTTP requests periodically.

      The amount of time between HTTP requests should be relatively brief and will not exceed the allows disconnect delay (see `setDisconnectDelay(long)`), 5 seconds by default.

      The default size is 100.

    - #### setWebSocketEnabled

          public SockJsServiceRegistration setWebSocketEnabled(boolean webSocketEnabled)

      Some load balancers don't support WebSocket. This option can be used to disable the WebSocket transport on the server side.

      The default value is "true".

    - #### setTransportHandlers

          public SockJsServiceRegistration setTransportHandlers(TransportHandler... handlers)

    - #### setTransportHandlerOverrides

          public SockJsServiceRegistration setTransportHandlerOverrides(TransportHandler... handlers)

    - #### setInterceptors

          public SockJsServiceRegistration setInterceptors(HandshakeInterceptor... interceptors)

    - #### getSockJsService

          protected SockJsService getSockJsService()