我正在使用Node + JS + socket.io應用程序。Node JS + Socket.io應用程序在一段時間後停止接收事件
整個應用程序工作正常,但大約5分鐘後服務器停止接收客戶端觸發的事件。 :(
當事件不會被觸發,我可以看到服務器成功接受心臟的跳動。
debug - got heartbeat packet
debug - cleared heartbeat timeout for client 4cKMC4Iqje-7dDfibJZm
debug - set heartbeat interval for client 4cKMC4Iqje-7dDfibJZm
debug - emitting heartbeat for client 4cKMC4Iqje-7dDfibJZm
debug - websocket writing 2::
debug - set heartbeat timeout for client 4cKMC4Iqje-7dDfibJZm
我也相信,該客戶端發出的消息,因爲我可以看到該數據在Chrome開發者工具發送。 以下是正在發送
5:::{"name":"ev_SendChatMessage","args":[{"chatMsg":"dgdfsgfs","aID":"10010001835364"}]}
而且,我已經檢查TCP轉儲的結果在服務器端機器的樣本數據,它成功接收數據包ETS。
節點版本是v0.10.21
socket.io版本0.9.16
客戶端代碼
var socket;
$(function()
{
// Connect to the Live Proctoring Server.
socket = io.connect('http://autoproc.am.in:8899');
});
function SendChatMsg()
{
// This get called on click of a button
socket.emit("ev_SendChatMessage", { chatMsg : "textToSend", aID : "123" });
}
服務器代碼
var options = {};
var io = require('socket.io').listen(8899, options);
// Called when a connection is made with a new Client
function OnConnection (socket)
{
console.log("Connection has been made with " + socket.id);
socket.on('ev_SendChatMessage', SendChatMessageFromModerator);
socket.on('disconnect', OnDisconnect);
}
// This stops getting called after some time. In the beginning it is getting called successfully.
function SendChatMessageFromModerator(data)
{
console.log(data);
}
編輯:更準確地說這種事情發生只有在aro之後並收到7-8條消息併發出7-8條消息。
編輯:我試圖將傳輸機制從Web Socket更改爲「xhr-polling」。即使那樣我也面臨同樣的問題,而我可以在調試中看到有價值的東西。
debug - xhr-polling received data packet 5:::{"name":"ev_SendChatMessage","args":[{"chatMsg":"sfsdfdsfs","aID":"10010001167896"}]}
debug - clearing poll timeout
debug - xhr-polling writing 8::
debug - set close timeout for client JfaWyiP3YqTRmqyzz4z6
debug - xhr-polling closed due to exceeded duration
debug - setting request GET /socket.io/1/xhr-polling/JfaWyiP3YqTRmqyzz4z6?t=1389965419417
debug - setting poll timeout
debug - discarding transport
debug - cleared close timeout for client JfaWyiP3YqTRmqyzz4z6
這清楚地表明數據已經到達Node JS應用程序。
你可以粘貼你到目前爲止工作的代碼嗎? – thepanuto
沒有一行代碼就很難找出問題所在......給我們一個鏈接或一些東西來處理。 – rafaelcastrocouto
其實它的很多代碼..請稍候,我將上傳一些精簡代碼.. – Manu