mthizo247 / spring-cloud-netflix-zuul-websocket

Zuul reverse proxy web socket support
Apache License 2.0
139 stars 72 forks source link

Websocket connection fails when request and websocket paths are different #2

Open afourmi opened 7 years ago

afourmi commented 7 years ago

If the websocket is exposed on a different path than the path request, the websocket connection will fail. In the following case, the websocket is exposed on http://localhost:10008/my-websocket And there is a zuul proxy with the following config:

zuul:
  routes:
    websocket:
      path: /ws/**
      url: http://localhost:10008
      customSensitiveHeaders: true
  ws:
     brokerages:
       websocket:
         end-points: /mywebsocket
         brokers:  /topic
         destination-prefixes: /

When the client connects to websocket with the url http://proxy/ws/mywebsocket, the zuul proxy does not route the call to localhost:10008 If I change the route configuration to reflect the route path:

end-points: /ws/mywebsocket

Then the websocket connection fails again with the following message: c.g.m.c.n.z.web.socket.ProxyWebSocketConnectionManager | Error connecting to web socket uri http://localhost:10008/ws/mywebsocket

There is a workaround to this problem, by setting both request path and websocket paths in the end-points parameter:

end-points: mywebsocket,ws/mywebsocket

Doing this, the previous message (Error connecting to web socket uri...) still appears, but the web socket connection succeeds. I guess that the endpoints are tried in order.

There should be a way to route web sockets calls, even if path differs betwen request path and host path.

mthizo247 commented 7 years ago

@afourmi thanks, I will look at this scenario as soon as i get a gap.