title: Java WebSocket Client Spring boot
body: <p>I want to create a spring boot app with a web socket client that connects to a web socket server.</p>
  
  <p>As an example, I used the Getting Started guide you can find in Spring Boot.</p>
  
  <p><a href="https://spring.io/guides/gs/messaging-stomp-websocket/" rel="nofollow noreferrer">https://spring.io/guides/gs/messaging-stomp-websocket/</a></p>
  
  <p>In this example, you create a web socket server using spring boot and you connect to it using JavaScript.</p>
  
  <p>I want to run that server and connect to it using another spring boot application that creates a WebSocketClient object.</p>
  
  <p>This is the WebSocketClientConfiguration class that I created in the Spring Boot client App</p>
  
  <pre><code>@Configuration
  @EnableWebSocketMessageBroker
  public class WebSocketClientConfig {
  
      @Bean
      public WebSocketClient webSocketClient() {
          final WebSocketClient client = new StandardWebSocketClient();
  
          final WebSocketStompClient stompClient = new WebSocketStompClient(client);
          stompClient.setMessageConverter(new MappingJackson2MessageConverter());
  
          final StompSessionHandler sessionHandler = new MyStompSessionHandler();
          stompClient.connect("ws://localhost:8080", sessionHandler);
          return client;
      }
  }
  </code></pre>
  
  <p>But in my class MyStompSessionHandler, in handleTransportError method I can see that the exception is </p>
  
  <pre><code>javax.websocket.DeploymentException: The HTTP response from the server [200] did not permit the HTTP upgrade to WebSocket
  </code></pre>
  
  <p>Any idea what I am doing wrong?</p>