WebSocket Handshake - Unexpected response code 200 - AngularJs and Spring Boot

后端 未结 3 1638
生来不讨喜
生来不讨喜 2020-12-31 07:54

When I tried to establish websocket communication between AngularJS app and Spring Boot I\'m getting the error: Error during websocket handshake - Unexpected respons

3条回答
  •  旧巷少年郎
    2020-12-31 08:41

    Can you try this WebsocketConfiguration configuration:

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

    so you have both websocket and SockJS configurations?

提交回复
热议问题