Socket.io code 200 Error during WebSocket handshake

前端 未结 2 457
一个人的身影
一个人的身影 2021-01-23 02:35

I am using socket.io with nodejs and an apache server over it. I am getting a code 200 as response, I know I must get

相关标签:
2条回答
  • 2021-01-23 03:07

    I use springboot 2 + stomp. In my case ,the reason is in WebSocketConfig,must remove .withSockJS.

    @Configuration
    @EnableWebSocketMessageBroker
    public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {
    
        @Override
        public void registerStompEndpoints(StompEndpointRegistry registry) {
            registry.addEndpoint("/ws").setAllowedOrigins("*")
                    .addInterceptors(new HandshakeInterceptor())
    
                    //--> important must remove,or 200 error.
                    //.withSockJS()
    
                    ;
        }
    
    0 讨论(0)
  • 2021-01-23 03:08

    This means your requests are not being proxied to your WebSocket handler, but for some other route which returns a 200.

    You should check your WebSocket handler.

    0 讨论(0)
提交回复
热议问题