Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.9k views
in Technique[技术] by (71.8m points)

node.js - Socket io chat - disconnecting clients randomly ping timeout and transport close errors ver 2.2.0

I have a chat app running on Node JS express with Socket io.

Previously clients were getting disconnected when they send a large picture over 4 MB, i found out socket io cannot handle/stream/send such large data in Base64 over socket emit events. So I ended up using this socket io file upload module. Now I am using socket io file upload module to let users upload pics/files during their chats. Now even if i upload biggest images/files chat doesn't get disconnect.

However, clients are still getting randomly disconnected with many errors like ping timeout, transport close etc even when they are simply doing text chat.

Below are my socket io client and server configs, I have tried playing around with pingTimeout , & pingInterval values but still clients are getting disconnected.

Socket IO Client Configs:

socket io client

Socket IO server Configs:

socket io server

Client Side JS logs when chat disconnects:

JS console log when chat disconnects

My socket io client and server versions:

socket io versions

Similar issue but got no luck in trying any solution: https://github.com/socketio/socket.io/issues/2769

My app has mostly around 500-800 concurrent clients using it.

My Server Specs where app is deployed:

  • 32 GB RAM, 8 vCPUs, Ubuntu Lemp 16.04, Node ver 8.9.3

My questions:

  1. What should be my socket io client and server optimal configurations like pingTimeout and pingInterval etc settings to eliminate random disconnections issues ?
  2. Do i need to upgrade my server specs to accommodate such traffic ? If so , how much and what should i upgrade?
    1. Could this be a reason that when many users are uploading files using the socket io file upload module, it caused socket io server to go out of memory which causes other clients to get disconnected? How do i stop this from happening?
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

It Should be consistent.

in client configs you have defined 'transports': ['polling' , "websocket"]; so it must be in server config also 'transports': ['polling', "websocket"]


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...