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

前提是你 提交于 2019-11-28 10:59:52

问题


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:

  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?

来源:https://stackoverflow.com/questions/56538814/socket-io-chat-disconnecting-clients-randomly-ping-timeout-and-transport-close

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!