0

我在我的 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)

谁能理解这可能意味着什么?

我的代码在我的本地机器上运行良好,只有将它移动到我的生产服务器时才会发生此错误。

4

1 回答 1

0

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

于 2013-03-03T01:43:39.307 回答