1. Problem description
During a websocket connection debugging, no mapping for GET exception was triggered, and no problem was found after checking the connection path;
2. Problem solving
2.1 Check websocket annotations
@ServerEndpoint("/path") @Component public class WebsocketDemoServer { }
2.2 Websocket related configuration supplement
@Configuration public class WebsocketConfig { @Bean public ServerEndpointExporter serverEndpointExporter() { return new ServerEndpointExporter(); } }
Tips
When using nginx to forward websockets, you need to do the following configuration
# Websocket related configuration location /ws { proxy_pass http://127.0.0.1:9999; #Protocol version. This must be written like this proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; #The connection remains constant, if there is no message resent within 600s, the connection will be disconnected proxy_read_timeout 600s; }
Summarize
The above is personal experience. I hope you can give you a reference and I hope you can support me more.