Socket.io当第一个服务器重新连接失败时,第二个服务器应该连接

Socket.io当第一个服务器重新连接失败时,第二个服务器应该连接,socket.io,connectivity,Socket.io,Connectivity,我得到了一个场景,我正在实现socket.io连接以将通知推送到所有客户端 sockets = io.connect("http://localhost:3000"); sockets.on("connection", function(socket){ socket.on('connect',function(data){ }); socket.on('reconnect_failed',function()

我得到了一个场景,我正在实现socket.io连接以将通知推送到所有客户端

    sockets = io.connect("http://localhost:3000");
       sockets.on("connection", function(socket){
            socket.on('connect',function(data){
             });
       socket.on('reconnect_failed',function(){
           console.log("reconnect_Failed");
               io.connect("http;//localhost:4000");
                 //Here i want to register a new socket when
                 // the first server is not able to reconnect
         });
      });
只有第一台服务器关闭时,请指导我注册。这样我可以避免在运行第一个服务器时注册第二个实例。。。这个代码有用吗。我的输出为null,不显示是否已连接。第一台服务器运行正常。

您有一个输入错误,http//

这应该做到:

socket.on('reconnect_failed',function(){
           console.log("reconnect_Failed");
               io.connect("http://localhost:4000");
                 //Here i want to register a new socket when
                 // the first server is not able to reconnect
         });
      });

请核对问题。在客户端将此问题扩展为另一个解决方案。请引导我以任何其他方式注册以在同一页面上工作。一旦问题得到回答,你就不能更改,这完全违背了本网站的目的。请单独发布你的新问题,我会看一看;