StompProtocolAndroid icon indicating copy to clipboard operation
StompProtocolAndroid copied to clipboard

Websocket connection closed error

Open kuppasekhar opened this issue 7 years ago • 2 comments

Hi Naik, I have tried to run the given sample to connect websocket from Andorid and running the backend code in spring boot like mentioned below. But I got the following error when I use .withSockJS() from backend side. 07-16 14:44:06.415 16043-16072/ua.naiksoftware.stompclientexample D/WebSocketsConnectionProvider: onClose: code=1002 reason=Invalid status code received: 200 Status line: HTTP/1.1 200 remote=false 07-16 14:44:06.419 16043-16072/ua.naiksoftware.stompclientexample D/AbstractConnectionProvider: Emit lifecycle event: CLOSED 07-16 14:44:06.421 16043-16043/ua.naiksoftware.stompclientexample E/MainActivity: Stomp connection error 07-16 14:44:06.421 16043-16043/ua.naiksoftware.stompclientexample I/MainActivity: Stomp connection closed

But If i don't use .withSockJS() from backend it runs successfully. Can you please check and do needful.

Please find the spring boot code below

@Configuration

@EnableWebSocketMessageBroker @EnableScheduling public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer {

@Override
public void configureMessageBroker(MessageBrokerRegistry config) {
    config.enableSimpleBroker("/topic");
    config.setApplicationDestinationPrefixes("/app");
}

@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
    registry.addEndpoint("/message/websocket").withSockJS();
}

}

Thanks, Sekhar Kuppa

kuppasekhar avatar Jul 16 '18 09:07 kuppasekhar

Duplicate of #49

forresthopkinsa avatar Jul 16 '18 18:07 forresthopkinsa

Use this library its working fine, replace server url and port with your custom server url and your port. https://github.com/SayyedUmar/Stomp-Android-Client

testGumar avatar May 01 '19 07:05 testGumar