[英]Socket-io can't handle more than 20 call per second
I'm trying to test an implementation of webcam streaming through socket-io.我正在尝试通过 socket-io 测试网络摄像头流的实现。
I thought that socket-io could handle many requests per second but my flask server crash when I exceed about 20 call per second to my socket-io listener.我认为 socket-io 每秒可以处理许多请求,但是当我每秒对 socket-io 侦听器的调用超过 20 次时,我的烧瓶服务器崩溃了。
Here is the code in my website :这是我网站上的代码:
setInterval(() => {
socket.emit(
"frame2server",
`It is currently ${Date.now()}!`
);
}, 50); // 50ms = 20 fps
And here is the socket-io code :这是socket-io代码:
@socketio.on("frame2server")
def handle_frame(frame):
socketio.emit("frame2client", frame)
Any ideas on the subject ?关于这个主题的任何想法?
It's because socket-io limits by default the number of calls per second.这是因为 socket-io 默认限制每秒的调用次数。 To fix that, you need to add :
要解决此问题,您需要添加:
from engineio.payload import Payload
Payload.max_decode_packets = 50
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.