Class SockJsClient

    • Method Detail

      • setHttpHeaderNames

        public void setHttpHeaderNames​(@Nullable
                                       String... httpHeaderNames)
        The names of HTTP headers that should be copied from the handshake headers of each call to doHandshake(WebSocketHandler, WebSocketHttpHeaders, URI) and also used with other HTTP requests issued as part of that SockJS connection, e.g. the initial info request, XHR send or receive requests.

        By default if this property is not set, all handshake headers are also used for other HTTP requests. Set it if you want only a subset of handshake headers (e.g. auth headers) to be used for other HTTP requests.

        Parameters:
        httpHeaderNames - the HTTP header names
      • getHttpHeaderNames

        @Nullable
        public String[] getHttpHeaderNames()
        The configured HTTP header names to be copied from the handshake headers and also included in other HTTP requests.
      • setInfoReceiver

        public void setInfoReceiver​(InfoReceiver infoReceiver)
        Configure the InfoReceiver to use to perform the SockJS "Info" request before the SockJS session starts.

        If the list of transports provided to the constructor contained an XhrTransport or an implementation of InfoReceiver that instance would have been used to initialize this property, or otherwise it defaults to RestTemplateXhrTransport.

        Parameters:
        infoReceiver - the transport to use for the SockJS "Info" request
      • setConnectTimeoutScheduler

        public void setConnectTimeoutScheduler​(TaskScheduler connectTimeoutScheduler)
        Configure a TaskScheduler for scheduling a connect timeout task where the timeout value is calculated based on the duration of the initial SockJS "Info" request. The connect timeout task ensures a more timely fallback but is otherwise entirely optional.

        By default this is not configured in which case a fallback may take longer.

        Parameters:
        connectTimeoutScheduler - the task scheduler to use
      • start

        public void start()
        Description copied from interface: Lifecycle
        Start this component.

        Should not throw an exception if the component is already running.

        In the case of a container, this will propagate the start signal to all components that apply.

        Specified by:
        start in interface Lifecycle
        See Also:
        SmartLifecycle.isAutoStartup()
      • stop

        public void stop()
        Description copied from interface: Lifecycle
        Stop this component, typically in a synchronous fashion, such that the component is fully stopped upon return of this method. Consider implementing SmartLifecycle and its stop(Runnable) variant when asynchronous stop behavior is necessary.

        Note that this stop notification is not guaranteed to come before destruction: On regular shutdown, Lifecycle beans will first receive a stop notification before the general destruction callbacks are being propagated; however, on hot refresh during a context's lifetime or on aborted refresh attempts, a given bean's destroy method will be called without any consideration of stop signals upfront.

        Should not throw an exception if the component is not running (not started yet).

        In the case of a container, this will propagate the stop signal to all components that apply.

        Specified by:
        stop in interface Lifecycle
        See Also:
        SmartLifecycle.stop(Runnable), DisposableBean.destroy()
      • isRunning

        public boolean isRunning()
        Description copied from interface: Lifecycle
        Check whether this component is currently running.

        In the case of a container, this will return true only if all components that apply are currently running.

        Specified by:
        isRunning in interface Lifecycle
        Returns:
        whether the component is currently running
      • clearServerInfoCache

        public void clearServerInfoCache()
        By default the result of a SockJS "Info" request, including whether the server has WebSocket disabled and how long the request took (used for calculating transport timeout time) is cached. This method can be used to clear that cache hence causing it to re-populate.