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 server Configs:
Client Side JS logs when chat disconnects:
My socket io client and server 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:
- What should be my socket io client and server optimal configurations like pingTimeout and pingInterval etc settings to eliminate random disconnections issues ?
- Do i need to upgrade my server specs to accommodate such traffic ? If so , how much and what should i upgrade?
- 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 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…