Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Websocket over Spring Netflix Zuul

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?

like image 859
Jakub Narloch Avatar asked Aug 18 '15 17:08

Jakub Narloch


1 Answers

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.

like image 148
Jakub Narloch Avatar answered Oct 07 '22 12:10

Jakub Narloch