Multiple websocket servers on one machine

1.5k Views Asked by At

I have been using socket cluster to setup socket servers. Is there anyway to use multiple socket cluster running on same machine on same port?

Ex:

App connects to ws://server.com/app-one Another App connects to ws://server.com/app-two

1

There are 1 best solutions below

3
On

Is there anyway to use multiple socket cluster running on same machine on same port?

No. Not directly. You need some sort of other process to serve as a proxy to separate out the incoming connections on your main port and then forward then to the appropriate cluster (each of which would be running on a different port).

So, a proxy process would be running on your main port whatever that was. Each websocket cluster would be running on its own unique port. An incoming connection would arrive at the proxy and then be forwarded to the right socketcluster. My guess is that you could use NGINX as your proxy and configure it to route to the right cluster based on path.