Spring-cloud-gateway: Websockets PING message from server lost when using Gateway

Created on 20 Dec 2018  ·  30Comments  ·  Source: spring-cloud/spring-cloud-gateway

Currently, we have a Websocket server under Cloud Gateway, everything's working fine until we try to send PING messages from the server to the client. Without the Gateway the PING messages are received fine, but when using the gateway the client receives none.

bug

Most helpful comment

Hi Folks, my fix for this in reactor-netty was merged today per https://github.com/reactor/reactor-netty/pull/927 and I have the subsequent fixes ready for spring-framework and this project once it is released.

All 30 comments

Can you provide a complete, minimal, verifiable sample that reproduces the problem? It should be available as a GitHub (or similar) project or attached to this issue as a zip file.

hello Ryan, I've created this project for reproducing the problem. Looking forward to your feedback.

Sorry but my node knowledge is out of date, when I run node ws-client I get

module.js:559
    throw err;
    ^

Error: Cannot find module './lib/websocket'
    at Function.Module._resolveFilename (module.js:557:15)
    at Function.Module._load (module.js:484:25)
    at Module.require (module.js:606:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/Users/ryanjbaxter/temp/issues/729/cloud-gateway-websockets-ping-message-bug/ws-client/node_modules/ws/index.js:3:19)
    at Module._compile (module.js:662:30)
    at Object.Module._extensions..js (module.js:673:10)
    at Module.load (module.js:575:32)
    at tryModuleLoad (module.js:515:12)
    at Function.Module._load (module.js:507:3)

using the following command: npm i ws should do the trick

I have made some progress with this issue, also updated the repo for reproducing this. Interestingly enough, It seems like PONG messages are received through the gateway, PING messages are still not received though. Please let me know if you still encounter issues in using the node client.

@adrianbrad
Hello, I am using the 2.0.2.RELEASE version and found that the gateway could not proxy the websocket ping request from the websocket service. The first picture does not use a proxy, and the second use spring cloud gateway proxy.
Ps:100.95.88.11 is a websocket service
10.119.187.253 is the browser's IP address
49339987-a1715b00-f674-11e8-8158-bed104abf22e
49339988-a7ffd280-f674-11e8-971c-864c2a56ff77

How did you solve this issue? Please help me introduce.

follow

@liuyanqing119 we did not solve this, we are sending just PONG messages at the moment, as they get through the gateway

@ryanjbaxter how to solve this issue?

@ryandawsonuk
Now, our issue is that jupyter notebok's websocket ping and pong messages cannot pass through the gateway. how to solve this issue?
You can try to build a jupyter notebook locally to reproduce this issue.

I am a little unfamiliar with the Websocket stuff by my feeling is that we probably need to do some extra proxying here https://github.com/spring-cloud/spring-cloud-gateway/blob/master/spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/filter/WebsocketRoutingFilter.java#L155

@spencergibb any thoughts?

I found the reason,in the package reactor-netty, the class WebsocketServerOperations response the ping frame in line 133.

This will require some work between myself, the netty folks and the framework folks

@spencergibb @coreey

When can this problem be fixed?

@spencergibb
@coreey

Recently, we have also encountered this problem. Our product will be released soon. It is urgent, urgent and urgent.

I don't know.

@spencergibb @coreey

Can you provide some suggestions for modification? I can modify the source code myself and repackage it.

I cannot. Something might need to change in Framework (not here).

This is now dependant on https://github.com/reactor/reactor-netty/issues/663 and a boot release that consumes it.

@liuyanqing119
@coreey
@adrianbrad

我也遇到了这个问题,我提交提交了一个 pull request 给reactor-netty.

希望对你们也有用。

深度截图_选择区域_20190512154936

Hi @spencergibb, are there any news related to this issue. We are also having troubles with the fact that ping messages are not forwarded.

Hi Folks, my fix for this in reactor-netty was merged today per https://github.com/reactor/reactor-netty/pull/927 and I have the subsequent fixes ready for spring-framework and this project once it is released.

Great. Once fixes make their way to framework and boot we can accept a PR.

Great. Once fixes make their way to framework and boot we can accept a PR.

@spencergibb @JacobASeverson
The pr just fix the clientside(WebsocketClientOperations)。How about WebsocketServerOperations? since Client can also send ping to server(which as proxy),if WebsocketServerOperations not do the same way,the upstream can not received ping from downstream。

Someone correct me if I'm wrong - but once the connection is upgraded and established between client and server through the gateway, the server's ping frames are handled by WebsocketClientOperations in the gateway as they arrive through the connection (at least that was the observed behavior when I tested my changes with an example project). I don't think we'll need the proposed changes to WebsocketServerOperations for ping functionality in this project.

@JacobASeverson if the downstream services need the pings it is a problem.

I see, for some reason I thought the websockets spec defined the direction of ping/pong frames more strictly which was why I didn't consider that use case. Thanks.

Hi Folks, my fix for this in reactor-netty was merged today per reactor/reactor-netty#927 and I have the subsequent fixes ready for spring-framework and this project once it is released.

@JacobASeverson looks like this was released (0.9.3.RELEASE) any update on the fixes... I tried looking for PRs but couldn't find anything.

@spencergibb is there any update on this? seems it has been fixed on reactor-netty side.

Was this page helpful?
0 / 5 - 0 ratings