簡體   English   中英

基於heroku socket.io服務器的heroku空閑連接超時

[英]heroku Idle connection timeout on heroku socket.io server based

有時我的套接字服務器引發以下問題:

這里的heroku日志:

heroku[router]: at=error code=H15 desc="Idle connection" method=GET path=/socket.io/1/websocket/RcjG0Zjot1U3uwLWX9SI 
host=www.*********.** request_id=69f5aa39-255b-4871-a928-1548ef2fdd4f 
fwd="217.200.201.210" dyno=web.1 connect=0 service=306473 status=503 bytes=870

我正在使用socket.io庫版本0.9.x和節點0.8.x. 它在heroku上托管並激活了websocket(heroku labs:啟用websockets -a myapp)。 我沒有使用xhr-polling

這是我如何實現套接字服務器:

var httpServer = http.createServer(function(request, response) {
  var pathname = url.parse(request.url).pathname;
  if(pathname == "/") pathname = "index.html";
  if(pathname.indexOf("/chat/") != -1  ) pathname = "index.html";
  var filename = path.join(process.cwd(), 'public', pathname);
  path.exists(filename, function(exists) {
    if(!exists) {
      response.writeHead(404, { "Content-Type": "text/plain" });
      response.write("404 Not Found");
      response.end();
      return;
    }
    response.writeHead(200, { 'Content-Type': mime.lookup(filename) });
    fs.createReadStream(filename, {
      'flags': 'r',
      'encoding': 'binary',
      'mode': 0666,
      'bufferSize': 4 * 1024
    }).addListener("data", function(chunk) {
      response.write(chunk, 'binary');
    }).addListener("close", function() {
      response.end();
    });
  });
});


socket_calls = new socket_calls(webSocket, io, connectedUsers,clients );
webSocket.sockets.on('connection',socket_calls.socket_callback_func );
httpServer.listen(process.env.PORT || 8080, "0.0.0.0");

這個問題似乎只出現在3g連接上,而且有些客戶報告說這些問題無法連接到服務器。

我嘗試使用“網絡鏈路調節器”來模擬連接錯誤,在3g連接和Wi-Fi連接的幾個設備上重現問題,但我無法重現錯誤。

我已經解決了。 這個問題只出現在3g與TIM職業生涯的聯系上。

我已經從heroku命令行工具禁用了websocket支持,我已經在socket.io上啟用了xhr-polling。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM