通常情况下,为了知道它已经启动,Node中的消息显示" info - socket.io已启动"。但是,出于某种原因,我没有得到它。可能是一个版本的东西。
那么还有另一种方法可以知道我的套接字是否已启动并正在侦听?
答案 0 :(得分:0)
您最近是否已将Socket.io从0.9版更新为1.x版?日志报告的默认值随版本1.0更改,默认情况下更简洁 请参阅upgrade文档。
PS:如果你升级了Socket.io并且你甚至没有意识到它,那么它是因为你的" package.json"文件没有锁定版本。我强烈建议AGAINST使用*
作为版本:始终更具体,将版本至少锁定到次要版本(根据semver)。例如:
// In package.json, under "dependencies":
// NOT SAFE: this always gets the last version, which may have some breaking change (as per semver, with version X.Y.Z, changes in X allow breaking changes in APIs)
"socket.io": "*"
// POSSIBLY SAFE: this does not update to the new major version, so API compatibility *should* be always maintained (however, it's not 100% safe too, to be used carefully)
"socket.io": "1.x"
// SAFE: this allows updates that contain bug fixes and minor additions; API-compatibility should always be guaranteed
"socket.io": "1.0.x"
"socket.io": "1.0.*" // equivalent
"socket.io": "~1.0.4" // equivalent