Redirecting socket.io/engine.io connection to another server

We are trying to find the best approach to our load balancing problem with websockets.

Websocket can first connect to any server, that server will run some logic, and then it will "redirect" the client to the appropriate server if needed.

Is there a way in socket.io/engine.io to redirect / forward connections?

Something like:

io.use(function(socket){
    // ... logic
    if(logic === true){
        socket.redirect("172.10.10.2:3000");
    }
});

      

I know this socket.redirect

is an invalid function, but is there something similar?

0


source to share


1 answer


socket.io doesn't support something like socket.redirect



But you can use Nginx to create a proxy for load balancing and use socket.io-redis to create socket.io adapter and descriptor across if(logic === true){}

multiple nodes.

0


source







All Articles