2013-03-02 104 views
0

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

任何人都可以理解這可能意味着什麼?

我的代碼在我的本地機器上工作正常,只有將它移動到我的生產服務器時纔會發生此錯誤。

+0

你使用的是什麼版本的Node? – Ryan 2013-03-02 15:18:10

+0

當你做socket.send('我的消息')?您需要在連接套接字時執行.send。 http://socket.io/#how-to-use – 2013-03-02 15:23:10

+0

@minitech Node中的更多信息僅在2天前安裝,所以假設它是最新版本。 – Rich 2013-03-02 15:28:54

回答

0

事實證明,這是因爲節點安裝了選項--without-ssl。這意味着它不會安裝socket.it所需的任何加密內容。我安裝了openssl,重新安裝了Node,並且這個固定了:)