Socket.io code 200 Error during WebSocket handshake

前端 未结 2 491
一个人的身影
一个人的身影 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()
    
                    ;
        }
    

提交回复
热议问题