java code with spring boot starter websocket
@Configuration @EnableWebSocket public class WsConfig implements WebSocketConfigurer { @Autowired UserWsHandler userWsHandler; @Autowired UserHandlerShakeHandler userHandlerShakeHandler; @Override public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) { registry.addHandler(userWsHandler,"/loginWs") .setAllowedOriginPatterns("*"); }
js
. const ws = new WebSocket("ws://10.12.36.178:8080/loginWs")
i got a EOFException when use chrome or edge.
Is something wrong with my code or my browser settings?
appreciates~
i am so stupid!
when use header 'Sec-Websocket-Protocol', the server must send back the same header.....