title: WebSocketStompClient won't connect to SockJS endpoint
body: <p>I'm playing around with the new (as of version 4.2) java STOMP client support.  My starting point is the getting started guide (<a href="http://spring.io/guides/gs/messaging-stomp-websocket/" rel="noreferrer">Using WebSocket to build an interactive web application</a>).</p>
  
  <p>The following endpoint is provided in the example:</p>
  
  <pre><code>@Override
  public void registerStompEndpoints(StompEndpointRegistry registry) {
      registry.addEndpoint("/hello").withSockJS();
  }
  </code></pre>
  
  <p>I can successfully connect using the browser client.  When attempting to connect to this endpoint using the java stomp client using the following:</p>
  
  <pre><code>WebSocketClient transport = new StandardWebSocketClient();
  WebSocketStompClient stompClient = new WebSocketStompClient(transport);
  stompClient.setMessageConverter(new StringMessageConverter());
  String url = "ws://127.0.0.1:8080/hello";       
  ListenableFuture&lt;StompSession&gt; future = stompClient.connect(url,myHandler);
  </code></pre>
  
  <p>I encounter the following exception:</p>
  
  <pre>08:56:30.629 [SimpleAsyncTaskExecutor-1] DEBUG o.s.m.simp.stomp.DefaultStompSession - Failed to connect session id=4e6737da-8f68-691d-375f-9e46f48bc149
  javax.websocket.DeploymentException: The HTTP response from the server [HTTP/1.1 200 OK
  ] did not permit the HTTP upgrade to WebSocket
      at org.apache.tomcat.websocket.WsWebSocketContainer.parseStatus(WsWebSocketContainer.java:637) ~[tomcat-embed-websocket-8.0.20.jar:8.0.20]
      at org.apache.tomcat.websocket.WsWebSocketContainer.processResponse(WsWebSocketContainer.java:621) ~[tomcat-embed-websocket-8.0.20.jar:8.0.20]
      at org.apache.tomcat.websocket.WsWebSocketContainer.connectToServer(WsWebSocketContainer.java:309) ~[tomcat-embed-websocket-8.0.20.jar:8.0.20]
      at org.springframework.web.socket.client.standard.StandardWebSocketClient$1.call(StandardWebSocketClient.java:152) ~[spring-websocket-4.2.0.BUILD-SNAPSHOT.jar:4.2.0.BUILD-SNAPSHOT]
      at org.springframework.web.socket.client.standard.StandardWebSocketClient$1.call(StandardWebSocketClient.java:149) ~[spring-websocket-4.2.0.BUILD-SNAPSHOT.jar:4.2.0.BUILD-SNAPSHOT]
      at java.util.concurrent.FutureTask.run(Unknown Source) [na:1.8.0]
      at java.lang.Thread.run(Unknown Source) [na:1.8.0] </pre>
  
  <p>Upon further investigation I changed the server endpoint configuration based on  TomcatWebSocketTestServer.java used in StompWebSocketIntegrationTests.java as follows:</p>
  
  <pre><code>RequestUpgradeStrategy upgradeStrategy = new TomcatRequestUpgradeStrategy();
  registry.addEndpoint("/hello")
      .setHandshakeHandler(new DefaultHandshakeHandler(upgradeStrategy))
      .setAllowedOrigins("*");
  </code></pre>
  
  <p>I can now connect, but the browser clients cannot.</p>
  
  <pre><code>GET http://localhost:8080/hello/info 404 (Not Found) 
  </code></pre>
  
  <p>If I add .withSockJs() to the endpoint configuration:</p>
  
  <pre><code>RequestUpgradeStrategy upgradeStrategy = new TomcatRequestUpgradeStrategy();
  registry.addEndpoint("/hello")
      .setHandshakeHandler(new DefaultHandshakeHandler(upgradeStrategy))
      .setAllowedOrigins("*")
      .withSockJs();
  </code></pre>
  
  <p>the browser clients can connect again, but the java client is back to the original error.</p>
  
  <p>Should I be able to share the same endpoint between both clients or do I need to configure two separate endpoints in this case?</p>