Unable to connect to the STOMP using stomp.js

147 views Asked by At
var stompClient = Stomp.over(function () {
return sock;
});

console.log("before con");

stompClient.connect({}, () => {
    setConnected;
    stompClient.subscribe("/topic/hello", (message) => {
        console.log(message);
    });
    console.log("runnable");
});
 

this is the code where I tried to connect to STOMP and I GOT Following Log

LOG  before con
LOG  Opening Web Socket...
LOG  Web Socket Opened...
LOG  >>> CONNECT
accept-version:1.2,1.1,1.0
heart-beat:10000,10000

But it does not recieve any message from the topic


@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {


    @Override
    public void registerStompEndpoints(StompEndpointRegistry registry) {
//        registry.addEndpoint("/ws").withSockJS();
        registry.addEndpoint("/ws").setAllowedOrigins("*");
    }

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


}

this is the springboot configuration I currently have

I tried using Postman by sending the Connect frame to the endpoint but no reply from the server.(Websocket connection was OK but only the STOMP connection gives me the headache)

CONNECT
accept-version:1.2
host:localhost

^@

this is the connect fram I have used

0

There are 0 answers