I want to create a spring boot app with a web socket client that connects to a web socket server.
As an example, I used the Getting Started guide you can find in Spring Boot.
https://spring.io/guides/gs/messaging-stomp-websocket/
In this example, you create a web socket server using spring boot and you connect to it using JavaScript.
I want to run that server and connect to it using another spring boot application that creates a WebSocketClient object.
This is the WebSocketClientConfiguration class that I created in the Spring Boot client App
@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;
}
}
But in my class MyStompSessionHandler, in handleTransportError method I can see that the exception is
javax.websocket.DeploymentException: The HTTP response from the server [200] did not permit the HTTP upgrade to WebSocket
Any idea what I am doing wrong?