问题
I have my websocket client developed in STOMP Java client (Spring project) and server implemented in Spring boot.
When the client/server handshake happens, I am getting a connection upgrade issue.
Java Client Code
List<Transport> transports = new ArrayList<>(1);
transports.add(new WebSocketTransport(new StandardWebSocketClient()));
SockJsClient sockjsClient = new SockJsClient(transports);
WebSocketStompClient stompClient = new WebSocketStompClient(sockjsClient);
stompClient.setMessageConverter(new MappingJackson2MessageConverter());
stompClient.setTaskScheduler(new ConcurrentTaskScheduler());
StompSessionHandler sessionHandler = new SessionHandler();
stompClient.connect("ws://localhost:9090/health", sessionHandler);
Server side
@Override
public void registerStompEndpoints(StompEndpointRegistry stompEndpointRegistry) {
stompEndpointRegistry.addEndpoint("/health")
.setAllowedOrigins("*")
.withSockJS();
}
@Override
public void configureMessageBroker(MessageBrokerRegistry registry) {
registry.enableSimpleBroker("/topic");
registry.setApplicationDestinationPrefixes("/app");
}
Exception generated at client side while connection to server
16:18:50.955/3771 [SimpleAsyncTaskExecutor-1] ERROR o.s.w.s.s.c.DefaultTransportRequest - No more fallback transports after TransportRequest[url=ws://localhost:9090/health/29/344d627baac949f5bab5506f05f1a7eb/websocket] javax.websocket.DeploymentException: The HTTP response from the server [200] did not permit the HTTP upgrade to WebSocket at org.apache.tomcat.websocket.WsWebSocketContainer.connectToServerRecursive(WsWebSocketContainer.java:434) at org.apache.tomcat.websocket.WsWebSocketContainer.connectToServerRecursive(WsWebSocketContainer.java:392) at org.apache.tomcat.websocket.WsWebSocketContainer.connectToServer(WsWebSocketContainer.java:194) at org.springframework.web.socket.client.standard.StandardWebSocketClient.lambda$doHandshakeInternal$0(StandardWebSocketClient.java:150) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.lang.Thread.run(Thread.java:745)
In the tomcat localhost_access_log I see the below request info
127.0.0.1 - - [01/Nov/2018:22:09:41 +0530] "GET /health/info HTTP/1.1" 302 - 0 127.0.0.1 - - [01/Nov/2018:22:09:41 +0530] "GET /login.jsp HTTP/1.1" 200 7649 16 127.0.0.1 - - [01/Nov/2018:22:09:41 +0530] "GET /health/191/6828a1fdefee40cf8dc74e825d8d2b0c/websocket HTTP/1.1" 302 - 0 127.0.0.1 - - [01/Nov/2018:22:09:41 +0530] "GET /login.jsp HTTP/1.1" 200 7649 0
I didn't find any info on how to fix this issue and what is causing it.
Please help me resolve this issue.
来源:https://stackoverflow.com/questions/53105701/the-http-response-from-the-server-200-did-not-permit-the-http-upgrade-to-webso