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

1

1

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?
Tulipwood answered 11/6, 2019 at 7:43 Comment(1)
I'm facing the same problem #65934610. Did you solved this?Ier
S
0

It Should be consistent.

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

Stricker answered 25/11, 2020 at 10:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.