简体   繁体   English

Socket-io 每秒不能处理超过 20 个调用

[英]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.

相关问题 Flask Socket-IO运行时未导入,并且导致许多问题,例如无法托管='0.0.0.0' - Flask Socket-IO Runs without Importing and causing many issues like can't host='0.0.0.0' 如何在点击事件中启动socket-io? - How can I launch socket-io on a click event? Flask Socket-IO 和 React socket.io-client,客户端不接收来自“emit”的消息 - Flask Socket-IO and React socket.io-client, client doesn't receive messages from 'emit Flask Socket-IO - 强制长轮询 - Flask Socket-IO - force long polling python asyncore模块可以处理/连接多个套接字吗? - Can python asyncore module handle/connect more than one socket? 如何使我的Flask服务器通过flask socket-IO向特定客户端发出消息 - How can I make my flask server emit messages through flask socket-IO to specific client 如何在没有客户端首先请求 python 和 flask 的情况下通过 socket-io 发送数据 - How can I send data though socket-io without the client requesting first with python and flask 每个HIT最多只能创建10个作业 - Can't create more than 10 assignments per HIT 每页最多只能抓取几个项目 - Can't crawl more than a few items per page Flask。 带有 gevent 的 Socket-io:[TypeError: 'module' object 不可调用] - Flask. Socket-io with gevent: [TypeError: 'module' object is not callable]
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM