如果节点服务器关闭.如何在 socket.io 上进行错误处理 [英] If node server is down. How to get error handling on socket.io
本文介绍了如果节点服务器关闭.如何在 socket.io 上进行错误处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何检测服务器状态?
var socket= io.connect('http://nodeserver.com:3000');
这是我的代码.如果 nodeserver.com:3000 已关闭,我如何验证服务器已关闭或已启动?
Here is my code. If nodeserver.com:3000 is down, how can i validate server down or up ?
我尝试了 connect_failed、error 事件,但没有奏效.
I tried connect_failed, error events but doesn't work.
推荐答案
你试过这样做吗?
this.socket.on('connect_error', function (err) {
//do something
});
换句话说,使用connect_error而不是connect_failed事件?
in other words, use the connect_error instead of the connect_failed event?
这篇关于如果节点服务器关闭.如何在 socket.io 上进行错误处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文