简体   繁体   English

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

[英]socket.io errors when client connects

I have socket.io running successfully on my node.js installation. 我的node.js安装上成功运行了socket.io。

info  - socket.io started

The console shows it running ok, but as soon as the client (browser) connects: 控制台显示它运行正常,但是一旦客户端(浏览器)连接,控制台就会:

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

The console is kicking out an error: 控制台踢出一个错误:

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)

can anyone understand what this might mean? 谁能理解这意味着什么?

My code has been working fine on my local machine, its only when moving it to my production server does this error happen. 我的代码在本地计算机上运行良好,只有将其移至生产服务器时才会发生此错误。

It turns out it's because Node was installed with the option --without-ssl. 事实证明是因为Node安装了--without-ssl选项。 This means it doesnt install any of the crypto stuff, which was needed by socket.it. 这意味着它不会安装socket.it所需的任何加密工具。 I installed openssl, reinstalled Node, and this fixed it :) 我安装了openssl,重新安装了Node,并对其进行了修复:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM