websocket connction question
when i use gateway to forward websocket connection . a problem was happend. eg:
2020-12-16 14:15:46.232 ERROR 76168 --- [nio-9442-exec-3] a.w.r.e.AbstractErrorWebExceptionHandler : [5898d92f] 500 Server Error for HTTP GET "/odv/ai_live/1_dbf7d70117f340a6a41b23dc346d8ef1"
java.lang.ClassCastException: org.apache.catalina.connector.ResponseFacade cannot be cast to reactor.netty.http.server.HttpServerResponse
at org.springframework.web.reactive.socket.server.upgrade.ReactorNettyRequestUpgradeStrategy.getNativeResponse(ReactorNettyRequestUpgradeStrategy.java:182) ~[spring-webflux-5.2.8.RELEASE.jar:5.2.8.RELEASE]
Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException:
Error has been observed at the following site(s):
|_ checkpoint ⇢ org.springframework.web.cors.reactive.CorsWebFilter [DefaultWebFilterChain]
|_ checkpoint ⇢ org.springframework.cloud.gateway.filter.WeightCalculatorWebFilter [DefaultWebFilterChain]
|_ checkpoint ⇢ HTTP GET "/odv/ai_live/1_dbf7d70117f340a6a41b23dc346d8ef1" [ExceptionHandlingWebHandler]
Stack trace:
at org.springframework.web.reactive.socket.server.upgrade.ReactorNettyRequestUpgradeStrategy.getNativeResponse(ReactorNettyRequestUpgradeStrategy.java:182) ~[spring-webflux-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.web.reactive.socket.server.upgrade.ReactorNettyRequestUpgradeStrategy.upgrade(ReactorNettyRequestUpgradeStrategy.java:162) ~[spring-webflux-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.web.reactive.socket.server.support.HandshakeWebSocketService.lambda$handleRequest$1(HandshakeWebSocketService.java:235) ~[spring-webflux-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at reactor.core.publisher.FluxFlatMap.trySubscribeScalarMap(FluxFlatMap.java:151) ~[reactor-core-3.3.9.RELEASE.jar:3.3.9.RELEASE]
at reactor.core.publisher.MonoFlatMap.subscribeOrReturn(MonoFlatMap.java:53) ~[reactor-core-3.3.9.RELEASE.jar:3.3.9.RELEASE]
at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:57) ~[reactor-core-3.3.9.RELEASE.jar:3.3.9.RELEASE]
at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52) ~[reactor-core-3.3.9.RELEASE.jar:3.3.9.RELEASE]
at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52) ~[reactor-core-3.3.9.RELEASE.jar:3.3.9.RELEASE]
at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52) ~[reactor-core-3.3.9.RELEASE.jar:3.3.9.RELEASE]
at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52) ~[reactor-core-3.3.9.RELEASE.jar:3.3.9.RELEASE]
at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52) ~[reactor-core-3.3.9.RELEASE.jar:3.3.9.RELEASE]
these my routeconfig
routes:
- id: odv-ws
uri: ws://localhost:8501
predicates:
- Path=/odv/ai_live/**
filters:
- StripPrefix=1
localhost:8501 is my websocketserver.。the websocketserver endpoint uses @ServerEndpoint.
connect eg: javascrtipt
var ws = new WebSocket("ws://localhost:9442/odv/ai_live/1_dbf7d70117f340a6a41b23dc346d8ef1");
localhost:9442 is my gateway.
i saw another issue said that "Gateway doesn't support tomcat. There is already an open issue for that". is it right?
I encountered it and did not solve it. I also configured it
`2020-12-17 20:21:41.049 WARN 288718 --- [or-http-epoll-6] r.netty.http.client.HttpClientConnect : [id: 0x27daedae, L:/192.168.3.26:52784 - R:192.168.3.26/192.168.3.26:9444] The connection observed an error
io.netty.handler.codec.http.websocketx.WebSocketHandshakeException: Invalid handshake response getStatus: 404 `
I encountered it and did not solve it. I also configured it
`2020-12-17 20:21:41.049 WARN 288718 --- [or-http-epoll-6] r.netty.http.client.HttpClientConnect : [id: 0x27daedae, L:/192.168.3.26:52784 - R:192.168.3.26/192.168.3.26:9444] The connection observed an error
io.netty.handler.codec.http.websocketx.WebSocketHandshakeException: Invalid handshake response getStatus: 404 `
我和你不一样 我是握手500,后来发现是因为不支持tomcat启动
I encountered it and did not solve it. I also configured it
2020-12-17 20:21:41.049 WARN 288718 --- [or-http-epoll-6] r.netty.http.client.HttpClientConnect : [id: 0x27daedae, L:/192.168.3.26:52784 - R:192.168.3.26/192.168.3.26:9444] The connection observed an error io.netty.handler.codec.http.websocketx.WebSocketHandshakeException: Invalid handshake response getStatus: 404我和你不一样 我是握手500,后来发现是因为不支持tomcat启动
Tomcat要8以上的,那你的是怎么写 我看看吗
i saw another issue said that "Gateway doesn't support tomcat. There is already an open issue for that". is it right?
Yes, here #1544 , Maybe soon for Tomcat and Undertow, Thanks @spencergibb for all of the work.
同样问题,解决了吗? @Sh1nno
Closing as a duplicate of #145