socketio-交换几条消息后未识别连接(?)

发布于 2025-02-11 12:03:02 字数 1149 浏览 0 评论 0原文

我正在运行JS socketio客户端和Python socketio服务器。工作流程大致是客户端发射Event1到服务器 - > 服务器对Event1做出反应,运行分析并发射Event2至Client - > 客户端再次接收Event2并再次发射Event1,但使用不同的ARGS - > 等,直到循环完成

问题是,由于某些原因,服务器日志显示出来的某些原因,此工作流程仅适用于两个迭代:

received event "event1" from None [/]
None is not connected to namespace /
received event "event1" from None [/]
None is not connected to namespace /
received event "event1" from None [/]
None is not connected to namespace /
received event "event1" from None [/]

我不知道可能是什么原因。我已经搜索了文档,但似乎找不到任何可能为此负责的参数。

客户:

import { io } from "socket.io-client";

export const socket = io("http://localhost:5550/",
{
  timeout: 200000000000
});

socket.emit('event1', args)
socket.on('event2', (msg) => {
        ...
        });

服务器:

app = Flask(__name__)
sio = socketio.Server(logger=True, cors_allowed_origins='*')
app.wsgi_app = socketio.WSGIApp(sio, app.wsgi_app)

if __name__ == '__main__':
    server = eventlet.wsgi.server(eventlet.listen(('', 5550)), app)

感谢您提供的任何帮助/提示,​​谢谢!

I'm running a JS socketio client and a Python socketio server. The workflow is roughly client emitting event1 to server -> server reacting to event1, running analysis and emitting event2 to client -> client receives event2 and emits event1 again but with different args -> etc until loop is complete

The problem is that this workflow only works for two iterations, for some reasons after that the server logs show:

received event "event1" from None [/]
None is not connected to namespace /
received event "event1" from None [/]
None is not connected to namespace /
received event "event1" from None [/]
None is not connected to namespace /
received event "event1" from None [/]

I have no idea whatsoever what might be the reason. I've searched through the docs but can't seem to find any parameters that might be responsible for that.

Client:

import { io } from "socket.io-client";

export const socket = io("http://localhost:5550/",
{
  timeout: 200000000000
});

socket.emit('event1', args)
socket.on('event2', (msg) => {
        ...
        });

Server:

app = Flask(__name__)
sio = socketio.Server(logger=True, cors_allowed_origins='*')
app.wsgi_app = socketio.WSGIApp(sio, app.wsgi_app)

if __name__ == '__main__':
    server = eventlet.wsgi.server(eventlet.listen(('', 5550)), app)

I appreciate any help/tips you can provide, thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文