Class JettyXhrTransport

java.lang.Object
org.springframework.web.socket.sockjs.client.AbstractXhrTransport
org.springframework.web.socket.sockjs.client.JettyXhrTransport
All Implemented Interfaces:
org.springframework.context.Lifecycle, InfoReceiver, Transport, XhrTransport

public class JettyXhrTransport extends AbstractXhrTransport implements org.springframework.context.Lifecycle
An XHR transport based on Jetty's HttpClient.

When used for testing purposes (e.g. load testing) the HttpClient properties must be set to allow a larger than usual number of connections and threads. For example:

 HttpClient httpClient = new HttpClient();
 httpClient.setMaxConnectionsPerDestination(1000);
 httpClient.setExecutor(new QueuedThreadPool(500));
 
Since:
4.1
Author:
Rossen Stoyanchev
  • Constructor Details

    • JettyXhrTransport

      public JettyXhrTransport(org.eclipse.jetty.client.HttpClient httpClient)
  • Method Details

    • getHttpClient

      public org.eclipse.jetty.client.HttpClient getHttpClient()
    • start

      public void start()
      Specified by:
      start in interface org.springframework.context.Lifecycle
    • stop

      public void stop()
      Specified by:
      stop in interface org.springframework.context.Lifecycle
    • isRunning

      public boolean isRunning()
      Specified by:
      isRunning in interface org.springframework.context.Lifecycle
    • connectInternal

      protected void connectInternal(TransportRequest transportRequest, WebSocketHandler handler, URI url, org.springframework.http.HttpHeaders handshakeHeaders, XhrClientSockJsSession session, CompletableFuture<WebSocketSession> connectFuture)
      Specified by:
      connectInternal in class AbstractXhrTransport
    • executeInfoRequestInternal

      protected org.springframework.http.ResponseEntity<String> executeInfoRequestInternal(URI infoUrl, org.springframework.http.HttpHeaders headers)
      Specified by:
      executeInfoRequestInternal in class AbstractXhrTransport
    • executeSendRequestInternal

      public org.springframework.http.ResponseEntity<String> executeSendRequestInternal(URI url, org.springframework.http.HttpHeaders headers, TextMessage message)
      Specified by:
      executeSendRequestInternal in class AbstractXhrTransport
    • executeRequest

      protected org.springframework.http.ResponseEntity<String> executeRequest(URI url, org.eclipse.jetty.http.HttpMethod method, org.springframework.http.HttpHeaders headers, @Nullable String body)