Whether Web socket using Stomp and Spring REST API Service can be on same project

Viewed 19

I have a Rest API service which will accept all the GET request and also post request in my web application.

      @GetMapping
      public ResponseEntity<Object> getRequest(HttpServletRequest 
             request,@RequestHeader Map<String,String> headers){

    Object response = null;
    *************
    *************
       }

I also have the web socket using Stomp which is registered with websocket

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

But when i call from the UI to connect with web socket it is going inside the rest api GET mapping instead of web socket Connection

     public connect() {
  console.log("Web Socket");
  this.socket = new SockJs(`http://localhost:28880/socket/ourwebsocket`, 
 { headers : {Authorization : 'Bearer <TOKEN>' }});
  this.stompClient = Stomp.over(this.socket);      
  return this.stompClient;
}
0 Answers
Related