Websocket java client Spring + Stomp: Transport error: ConnectionLostException
<p>I'm trying to create an standalone Java app as a websocket client using for this Spring with Stomp and Sockjs, taking in consideration the spring specifications and the spring-portafolio examples and I'm getting this error:</p>

<pre><code>15:18:01.342 [main] DEBUG com.example.client.WebSocketClientTest - Connecting to : ws://localhost:8080/socket/hello
15:18:01.541 [WebSocketClient-AsyncIO-1] ERROR com.example.client.MyStompSessionHandler - Transport error
org.springframework.messaging.simp.stomp.ConnectionLostException: Connection closed
at org.springframework.messaging.simp.stomp.DefaultStompSession.afterConnectionClosed(DefaultStompSession.java:483) [spring-messaging-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.web.socket.messaging.WebSocketStompClient$WebSocketTcpConnectionHandlerAdapter.afterConnectionClosed(WebSocketStompClient.java:354) [spring-websocket-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.web.socket.sockjs.client.AbstractClientSockJsSession.afterTransportClosed(AbstractClientSockJsSession.java:321) [spring-websocket-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.web.socket.sockjs.client.WebSocketTransport$ClientSockJsWebSocketHandler.afterConnectionClosed(WebSocketTransport.java:172) [spring-websocket-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter.onClose(StandardWebSocketHandlerAdapter.java:141) [spring-websocket-4.3.2.RELEASE.jar:4.3.2.RELEASE]...
</code></pre>

<p>My code in the java client side is: </p>

<pre><code>StandardWebSocketClient webSocketClient = new StandardWebSocketClient();
List&lt;Transport&gt; transports = new ArrayList&lt;&gt;();
transports.add(new WebSocketTransport(webSocketClient));
SockJsClient sockJsClient = new SockJsClient(transports);
ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
taskScheduler.afterPropertiesSet();
String stompUrl = "ws://localhost:8080/socket/hello";
WebSocketStompClient stompClient = new WebSocketStompClient(sockJsClient);
stompClient.setMessageConverter(new StringMessageConverter());
stompClient.setTaskScheduler(taskScheduler);
stompClient.setDefaultHeartbeat(new long[] {0, 0});

StompSessionHandler sessionHandler = new MyStompSessionHandler();
stompClient.connect(stompUrl, sessionHandler);
stompClient.setTaskScheduler(taskScheduler);
</code></pre>

<p>And the server side was made using Spring MVC with Stomp and SockJs, the server works perfectly with a javascript client, this is the config that I used: </p>

<pre><code>public void configureMessageBroker(MessageBrokerRegistry config) {
    config.enableSimpleBroker("/topic");
    config.setApplicationDestinationPrefixes("/app");
}
public void registerStompEndpoints(StompEndpointRegistry registry) {
    registry.addEndpoint("/hello")
            .setHandshakeHandler(new DefaultHandshakeHandler(new TomcatRequestUpgradeStrategy()))
            .withSockJS();
}
</code></pre>

<p>What am I doing wrong? Can anyone give me an idea of how to fix it or how to create a Java client to connect with an spring websocket server? </p>

<p>Thanks in advance.. </p>