问题描述
我有一个使用Socket io在Node JS Express上运行的聊天应用程序.
以前,当客户端发送超过4 MB的大图像时,客户端已断开连接,我发现套接字io无法通过套接字发出事件在Base64中处理/流/发送如此大的数据.因此,我最终使用了
套接字IO服务器配置:
聊天断开时客户端JS日志:
我的套接字io客户端和服务器版本:
类似的问题,但尝试任何解决方案都没有运气: https://github.comcom/socketio/socket.io/issues/2769
我的应用程序中大约有500-800个并发客户端在使用它.
我的服务器规范在哪里部署了应用程序
- 32 GB RAM,8个vCPU,Ubuntu Lemp 16.04,Node ver 8.9.3
我的问题:
- 我的套接字io客户端和服务器最佳配置是什么(例如pingTimeout和pingInterval等设置),以消除随机断开连接问题?
- 我是否需要升级服务器规格以适应此类流量?如果是这样,我应该升级多少?
- 这可能是当许多用户使用socket io文件上传模块上传文件时,导致Socket io服务器内存不足而导致其他客户端断开连接的原因吗?我如何阻止这种情况的发生?
应该一致.
在客户端配置中,您已经定义了'transports':['polling',"websocket"];因此它必须在服务器配置中也传输":['polling','websocket']
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?
It Should be consistent.
in client configs you have defined 'transports': ['polling' , "websocket"];so it must be in server config also 'transports': ['polling', "websocket"]
这篇关于套接字io聊天-随机断开客户端ping超时并传输关闭错误版本2.2.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!