Websocket over Spring Netflix Zuul
Asked Answered
A

3

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?

Abie answered 18/8, 2015 at 17:18 Comment(0)
A
9

Since, there is no answer, this is what I was able to find out about using Zuul with WebSockets.

My question was inaccurate in sense that I was using Sock.js and when connecting through Zuul Sock.js was recieving:

405 - Bad request

response, which immediatly made it fallback to xhr-straming, and this when it was able to made a connection, so

No it's not possible to use Websocket protocol overl Zuul.

But still I was facing the second issue, even when I was able to connect using fallback Sock.js transport the connection was being constantly closed by the proxy. Fortunetly Sock.js requires the server to "send" hearbeats every 10 seconds (by default), so adjusting the ribbon and hystrix timeouts you are able to maintain the "Sock.js connection" without special onerror reconection logic. So as described in the reference:

hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds: 60000 ribbon: ConnectTimeout: 3000 ReadTimeout: 60000

I've set this timeouts to double the time the Sock.js uses - so 20 seconds.

Still this is not native Websocket support.

I'm still looking for reasonable replacment for Zuul proxy, or some advice what other steps I could made to make that work.

Abie answered 22/8, 2015 at 19:54 Comment(2)
Thanks for this insightConsultative
Is it now possible to use Websocket protocol overl Zuul now?Percussionist
T
0

Have been looking at this issue, we have a similar requirement, to proxy websocket connections through a zuul server. The requirement is slightly different though because the websocket connections will be 'special' and won't need to be handled in the same way as other requests that come through zuul.

Previously this was really easy to achieve with nodejs and http-proxy. This is an example of how to get started in java and Spring Boot: https://github.com/barrett-rob/java-websocket-reverse-proxy

NB: no safety, connection reestablishment, etc

Trisect answered 23/6, 2017 at 4:40 Comment(0)
I
0

The question is already answered, but just in case someone comes here searching for a solution to Websockets with Zuul:

Since 2.0, Zuul supports this officially, here's the docs:
https://github.com/Netflix/zuul/wiki/Push-Messaging

Ireneirenic answered 22/11, 2018 at 8:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.