Netflix / zuul

Zuul is a gateway service that provides dynamic routing, monitoring, resiliency, security, and more.
Apache License 2.0
13.54k stars 2.39k forks source link

ZUUL- websocket #112

Open ctatineni opened 9 years ago

ctatineni commented 9 years ago

Hello,

is there a way to communicate using web sockets and MQ with zuul?

paskos commented 9 years ago

I'm very interested in the answer to that question too

NiteshKant commented 9 years ago

Zuul 2 uses RxNetty which supports WebSockets. There is no plan to support MQ but PRs are always welcome :)

thjaeckle commented 9 years ago

What's the status on websocket support in zuul 2? Will it work out of the box because using rxnetty?

NiteshKant commented 9 years ago

Websockets support in Zuul can be interpreted in two ways, viz.,

  1. Terminating Websockets as request-response: This would mean that Zuul is able to accept incoming WebSockets connections and by using some kind of request correlation executes its filter chain as a regular request-response.
  2. Embracing full-duplex channels: This would mean revamping Zuul filters to embrace full-duplex interactions and be able to accept and produce any full-duplex protocol like WS, HTTP/2, etc.

1 above can be somewhat achieved with Zuul 2.0 although some changes to the filter processing will be required in terms of assumptions around using HTTP 1.1 semantics. 2 is a bigger change out of scope of zuul 2.x.

In Netflix once, 2.x is stable, we will be working on implementing Reactive Sockets with Zuul which is essentially case 2 above.

jonfreedman commented 7 years ago

Is there any ETA for a production release of 2.0 which could then be used in Spring Cloud? It seems the new spring-cloud-gateway project may replace Zuul but that is not production ready yet either.

ermik commented 6 years ago

I'm looking for an edge / elb solution for websockets — in my case I am not sending anything back to the client, so terminating into POST would be possible. But there is still no clear example of how to do that. Any advice?

vklein commented 6 years ago

Are there some news about websocket support in Zuul 2.1?

artgon commented 6 years ago

Yes, we are definitely planning to add it.

MolaramSudaram commented 6 years ago

@artgon Thank you very much. That sounds promising. Websocket support would push us forward with our IoT solution. Do you have an idea or a feeling when we can count on websocket support?

cmdavinder commented 6 years ago

Hi there, Just wondering if there is a ballpark date for Websockets suport? Thanks.

artgon commented 6 years ago

The functionality is there in the sample app right now, just waiting on documentation. @raksoras can provide more details.

artgon commented 6 years ago

Here's the wiki page: https://github.com/Netflix/zuul/wiki/Push-Messaging

kasibkismath commented 5 years ago

@artgon thanks for the wiki. However, I'm having issues while integrating it over SockJS-client and Zuul 2, where I've configured the websocket server's IP and Port for the api.ribbion.listOfServers.

Any working sample of the above kind would suffice or is there something I'm missing?

raksoras commented 5 years ago

@kasibkismath Are you trying to proxy WebSocket through Zuul to your background SockJS server? Proxying WebSockets is not yet supported in Zuul 2. Zuul can accepts WebSockets from frontend clients and send messages over those WebSockets to those client when triggered from the backend but it can't proxy WebSockets to another backend server yet. We may add that functionality in Zuul in future.

kasibkismath commented 5 years ago

@raksoras Yes, I'm trying to proxy my request from client to the backend server via Zuul using WebSocket. This particular statement is quite confusing - "Zuul can accepts WebSockets from frontend clients and send messages over those WebSockets to those client when triggered from the backend", can you please elaborate on this please?

raksoras commented 5 years ago

Current version of Zuul supports accepting WebSockets and holding them open so that your backend servers can push messages to your clients over those WebSockets in response to events happening in the backend. You can send (or "push") messages over the WebSocket by connecting to Zuul server on it's internal only "send-push-message" port. Take a looK at this package and specifically at this initialization. This functionality is somewhat similar to push services like APNS or GCM where the client maintains persistent ongoing connection with server and then server can push messages from the cloud to the client whenever it has something for the client.

What Zuul does NOT support today is generic WebSocket proxying. That is, accept a WebSocket connection at proxy layer and then relay or proxy frames back to a WebSocket on a backend service. It's something on our roadmap for Zuul but not implemented yet.

For more context you can see this presentation

Hope this helps.

kasibkismath commented 5 years ago

@raksoras thanks a lot for the detailed explanation and for the references.

kasibkismath commented 5 years ago

@raksoras I've tried to push the message to the default push port - 7008, from the WebSocket backend which is built in Spring Boot using the sendTo annotation which has the absolute uri for testing purposes. However, I can't see the push message from the server to appear.

raksoras commented 5 years ago

What error/HTTP response code are you getting back from the server when you try to push the message to the client?

Are you trying with com.netflix.zuul.sample.SampleServerStartup included in the sample? If yes, make sure you are sending in a cookie named "userAuthCookie" with some customerId (for example, 1234) as its value when you open a WebSocket connection to Zuul server. Then you can connect to the same Zuul instance on port 7008 ("server_ip:7008/push") and do a POST with your message body and a special header "X-CUSTOMER_ID: 1234" to send the push message to that specific client. To have the push message successfully delivered, the customerId value in "userAuthCookie" in the original WebSocket connect request and the value of the header "X-CUSTOMER_ID" in the subsequent push message POST request must match.

Couple of things to keep in mind:

  1. SampleServerStartup is there just to explain the concepts. The UserAuth used by it for push is very insecure. You shouldn't run it in production without replacing it with your own production-grade user auth implementation. You can easily do so by replacing SamplePushAuthHandler with your own subclass of PushAuthHandler.
  2. The Sample server example works only in case of a single WebSocket server. If you run a cluster of WebSocket servers behind a load balancer then the in memory client connection registry used by the sample sever won't cut it. You need to replace it with a out of box registry that runs on it's own instance. Something like Redis is particularly suitable for the job of out of process client connection registry
ashertoqeer commented 5 years ago

@kasibkismath you can find a working demo here: Zuul 2 Push Messaging Sample I have written a blog post explaining how things are working.

mohammadrafigh commented 3 years ago

Do you still have a plan to add Websocket proxy?

artgon commented 3 years ago

Yes! It's on the roadmap for the coming 6-12 months.