5

With respect to this issue: https://github.com/spring-cloud/spring-cloud-netflix/issues/163 is there a reasonable way to setup Spring Cloud Zuul reverse proxy to be used with Websockets?

I was able to setup the proxy to websocket endpoint and sucessfully connect to it from the client, but due to very short connection timeouts the connections constantly gets closed. What I care the most at this point is the Zuul service autodiscovery. Does it make any sense to try to use similar workaround as for the file downloads described in the reference, although with larger connection timeouts?

Are the are any reasonable alternatives? Like writing my own ZuulFilter?

4

3 回答 3

9

由于没有答案,这就是我能够找到的关于将 Zuul 与 WebSockets 结合使用的信息。

我的问题是不准确的,因为我正在使用 Sock.js,并且当通过 Zuul Sock.js 连接时收到:

405 - 错误请求

响应,这立即使它回退到 xhr-straming,并且当它能够建立连接时,所以

不,不可能在 Zuul 上使用 Websocket 协议。

但是我仍然面临第二个问题,即使我能够使用后备 Sock.js 传输连接,代理也会不断关闭连接。幸运的是,Sock.js 要求服务器每 10 秒“发送”一次心跳(默认情况下),因此调整功能区和 hystrix 超时,您无需特殊的 onerror 重新连接逻辑即可维持“Sock.js 连接”。因此,如参考文献中所述:

hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds:60000 功能区:ConnectTimeout:3000 ReadTimeout:60000

我已将此超时设置为 Sock.js 使用时间的两倍——即 20 秒。

这仍然不是本机 Websocket 支持。

我仍在寻找 Zuul 代理的合理替换,或者一些建议我可以采取哪些其他步骤来完成这项工作。

于 2015-08-22T19:54:10.387 回答
0

一直在看这个问题,我们也有类似的需求,通过zuul服务器代理websocket连接。不过,要求略有不同,因为 websocket 连接将是“特殊的”,并且不需要以与通过 zuul 发出的其他请求相同的方式处理。

以前,这很容易通过 nodejs 和 http-proxy 实现。这是一个如何开始使用 java 和 Spring Boot 的示例:https ://github.com/barrett-rob/java-websocket-reverse-proxy

注意:没有安全,连接重建等

于 2017-06-23T04:40:56.253 回答
0

这个问题已经回答了,但以防有人来这里用 Zuul 寻找 Websockets 的解决方案:

自 2.0 起,Zuul 正式支持此功能,文档如下:
https ://github.com/Netflix/zuul/wiki/Push-Messaging

于 2018-11-22T08:28:04.077 回答