Netflix / zuul

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

Zuul 2 and Websocket Integration #551

Closed kasibkismath closed 2 weeks ago

kasibkismath commented 5 years ago

Lately, I've been working on Zuul 2 push that is the websocket integration. I have got a sample spring boot websocket app which works well without Zuul 2 integration. However, I do have problems integrating the sample app together with the Zuul 2, thus routing all the connect, disconnect and send message activities via Zuul 2.

//start of main.js extract
function connect() {
    var socket = new SockJS('http://localhost:7001/gs-guide-websocket');
    stompClient = Stomp.over(socket);
    stompClient.connect({}, function (frame) {
        setConnected(true);
        console.log('Connected: ' + frame);
        stompClient.subscribe('http://localhost:7008/topic/greetings', function (greeting) {
            showGreeting(JSON.parse(greeting.body).content);
        });
    });
}

function sendName() {
    stompClient.send("http://localhost:7001/app/hello", {}, JSON.stringify({'name': $("#name").val()}));
}
//end of main.js extract

Following the sample app for Zuul 2, the SampleServerStartup class has been modified to take the _SERVERTYPE as WEBSOCKET, therefore we have two ports which are being used according to the sample that are 7001 and 7008 for zuul.server.port.main and zuul.server.port.http.push respectively.

api.zuul.listOfServer is pointing to the spring boot app which servers the websocket backend.

However when sending the message it doesn't go anywhere and there is no clue whether these configurations are correct. If not what Am I missing?

Note: I'm using sockjs-client and STOMP

susheel-aroskar commented 5 years ago

Zuul server doesn't yet support proxying WebSocket connection. It allows client to maintain an open connection with the server and then push messages to the client, on that WebSocket, by sending those messages to zuul.server.port.http.push port (7008 by default). It won't proxy inbound WebSocket messages to the backend.

gigi commented 5 years ago

Hi! Do you have any plans to implement routing for inbound messages independently from transport? I think it sounds good to use already established WebSocket connection for any async client-server communication.

Request message can be smth like this

{
    "service": "payment", 
    "rpcLikeCall": "pay",
    "someMetaInformation": {"token": "value"},
    "body": {"sum":"10.00", "anyOtherKey": "value"}
}

This message will be send to payment's service url. Then pushed back to client via websocket

Thanx!

raksoras commented 5 years ago

It's something we want to look at in future but not a high priority for us right now.

mehdiaitbouallal commented 5 years ago

Hi ! Did you manage to solve this problem somehow ??

github-actions[bot] commented 3 weeks ago

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] commented 2 weeks ago

This issue was closed because it has been stalled for 7 days with no activity.