Error during WebSocket handshake: Unexpected response code: 200

hewending 发布于 2017/03/28 12:36
阅读 1K+
收藏 0

Error during WebSocket handshake: Unexpected response code: 200

这是服务器配置:

@Configuration
@EnableWebMvc
@EnableWebSocket
@RequestMapping("/gpsConfig")
public class GpsWebSocketConfig extends WebMvcConfigurerAdapter implements WebSocketConfigurer {
    
    @RequestMapping("/gpsTrigger")
    public void messageTrigger(){
    }
    
    public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
registry.addHandler(gpsWebSocketHandler(), "/gpsweb/warn").setAllowedOrigins("*").addInterceptors(gpsInterceptor());
    }

    @Bean
    public GpsWarnWebSocketHandler gpsWebSocketHandler() {
        return new GpsWarnWebSocketHandler();
    }
   

    @Bean
    public GpsHandshakeInterceptor gpsInterceptor() {
        return new GpsHandshakeInterceptor();
    }
}

var webSocket = 
            new WebSocket('ws://localhost:8080/hx-gps-platform/gpsweb/warn');

加载中
0
maple---
maple---

题主问题解决了吗,我也遇到了同样的问题

返回顶部
顶部