1
回答
Error during WebSocket handshake: Unexpected response code: 200
利用AWS快速构建适用于生产的无服务器应用程序,免费试用12个月>>>   

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');

<无标签>
举报
hewending
发帖于9个月前 1回/1K+阅
顶部