客户端连接时出现socket.io错误

时间:2013-03-02 15:16:44

标签: javascript node.js socket.io

我在我的node.js安装上成功运行了socket.io。

info  - socket.io started

控制台显示它运行正常,但是一旦客户端(浏览器)连接:

socket = io.connect('<my host>:8000');

控制台正在发出错误:

crypto.js:123
  return new Hash(hash);
         ^
TypeError: undefined is not a function
    at Object.createHash (crypto.js:123:10)
    at WebSocket.onSocketConnect (/node_modules/socket.io/lib/transports/websocket/hybi-16.js:120:23)
    at WebSocket.handleRequest (/node_modules/socket.io/lib/transport.js:71:10)
    at WebSocket.Transport (/node_modules/socket.io/lib/transport.js:31:8)
    at new WebSocket (/node_modules/socket.io/lib/transports/websocket/hybi-16.js:59:13)
    at new WebSocket (/node_modules/socket.io/lib/transports/websocket.js:31:17)
    at Manager.handleClient (/node_modules/socket.io/lib/manager.js:661:19)
    at Manager.handleUpgrade (/node_modules/socket.io/lib/manager.js:618:8)
    at Server.<anonymous> (/node_modules/socket.io/lib/manager.js:123:10)
    at Server.emit (events.js:88:20)

任何人都可以理解这可能意味着什么吗?

我的代码在本地计算机上运行正常,只有在将其移动到生产服务器时才会发生此错误。

1 个答案:

答案 0 :(得分:0)

事实证明这是因为Node安装了选项--without-ssl。这意味着它不会安装socket.it所需的任何加密内容。我安装了openssl,重新安装了Node,并修复了它:)

相关问题