【python】python-socketio+firecamp使用踩坑指南
server.py:
import eventlet
import asyncioeventlet.monkey_patch()import socketio
import eventlet.wsgisio = socketio.Server(async_mode='eventlet', cors_allowed_origins='*') # 指明在evenlet模式下@sio.event
def connect(sid, environ):print(f"connect, sid={sid}, environ={environ}")@sio.event
def disconnect(sid):print('disconnect ', sid)@sio.on('hello')
def hello(sid, data):print('server receive:', data)print("-----")sio.emit('world', {'data': 'world' + data})app = socketio.Middleware(sio)
eventlet.wsgi.server(eventlet.listen(('127.0.0.1', 9000)), app)
client.py
import socketiosio = socketio.Client()@sio.on('connect')
def on_connect():print("client connect")@sio.on('world')
def world(data):print('client receive:', data)sio.connect('http://127.0.0.1:9000')
sio.emit("hello", {"data": "hello"})
print('client send hello success')
server端代码运行成功之后,再运行client端代码,通过log可以看两端通信正常;
server
D:\softwsss/demo2/server.py
(5104) wsgi starting up on http://127.0.0.1:9000
client
D:\software_install\Anaconda3\python.exe D:/python/office_txt/axera/demo2/client.py
client connect
client send hello success
client receive: {'data': 'world'}
server端日志更新
(5104) accepted ('127.0.0.1', 5615)
server receive: {'data': 'hello'}
现在我们用接口调试工具firecamp代替客户端对服务端进行请求操作;
出师不利,刚开始连接就遇到了这么一个报错

detail:
(13392) accepted ('127.0.0.1', 4824)
The client is using an unsupported version of the Socket.IO or Engine.IO protocols (further occurrences of this error will be logged with level INFO)
127.0.0.1 - - [19/Nov/2022 17:25:56] "GET /socket.io/?EIO=3&transport=polling&t=OIFDNAH HTTP/1.1" 400 219 0.001000

查看下第三方包的安装版本,主要焦点集中在python-engineio 与python-socketio
pip list
python-engineio 4.3.4
python-socketio 5.7.2
官方作者给的各版本对应的关系:

refs:
https://pypi.org/project/python-socketio/
更新版本:
安装:
pip install python-socketio==4.6.0
python-engineio 4.3.4
python-socketio 4.6.0
查询python-engineio所有版本
pip index versions python-engineio --trusted-host pypi.mirrors.ustc.edu.cnWARNING: pip index is currently an experimental command. It may be removed/changed in a future release without prio
r warning.
python-engineio (4.3.4)
Available versions: 4.3.4, 4.3.3, 4.3.2, 4.3.1, 4.3.0, 4.2.1, 4.2.0, 4.1.0, 4.0.1, 4.0.0, 3.14.2, 3.14.1, 3.14.0, 3
.13.2, 3.13.1, 3.13.0, 3.12.1, 3.12.0, 3.11.2, 3.11.1, 3.11.0, 3.10.0, 3.9.3, 3.9.2, 3.9.1, 3.9.0, 3.8.2.post1, 3.8
.2, 3.8.1, 3.8.0, 3.7.0, 3.6.0, 3.5.2, 3.5.1, 3.5.0, 3.4.4, 3.4.3, 3.4.2, 3.4.1, 3.4.0, 3.3.2, 3.3.1, 3.3.0, 3.2.3,3.2.2, 3.2.1, 3.2.0, 3.1.2, 3.1.1, 3.1.0, 3.0.0, 2.3.2, 2.3.1, 2.3.0, 2.2.0, 2.1.1, 2.1.0, 2.0.4, 2.0.3, 2.0.2, 2.
0.1, 2.0.0, 1.7.0, 1.6.1, 1.6.0, 1.5.4, 1.5.3, 1.5.2, 1.5.1, 1.5.0, 1.4.0, 1.3.2, 1.3.1, 1.3.0, 1.2.4, 1.2.3, 1.2.2
, 1.2.1, 1.2.0, 1.1.2, 1.1.1, 1.1.0, 1.0.4, 1.0.3, 1.0.2, 1.0.1, 1.0.0, 0.9.2, 0.9.1, 0.9.0, 0.8.8, 0.8.7, 0.8.6, 0
.8.5, 0.8.4, 0.8.3, 0.8.2, 0.8.1, 0.8.0, 0.7.2, 0.7.1, 0.7.0, 0.6.9, 0.6.8, 0.6.7, 0.6.6, 0.6.5, 0.6.4, 0.6.3, 0.6.
2, 0.6.1, 0.6.0, 0.5.1, 0.5.0, 0.4.0, 0.3.1, 0.3.0, 0.2.0, 0.1.0INSTALLED: 4.3.4LATEST: 4.3.4
pip install python-engineio==3.14.0
一开始想找3.6.0版本安装,竟然有个报错,至少支持3.13.0,索性就安装3.14.0这个版本了;
安装时的报错:
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This beh
aviour is the source of the following dependency conflicts.
python-socketio 4.6.0 requires python-engineio>=3.13.0, but you have python-engineio 3.6.0 which is incompatible.
Successfully installed python-engineio-3.6.0
安装成功log:
pip install python-engineio==3.14
Looking in indexes: http://pypi.mirrors.ustc.edu.cn/simple/
Collecting python-engineio==3.14Downloading https://mirrors.bfsu.edu.cn/pypi/web/packages/4c/93/0dbe3e3e43a19c9a0279dde66e15889013682f896187ca777
551de8cc7be/python_engineio-3.14.0-py2.py3-none-any.whl (51 kB)---------------------------------------- 51.7/51.7 KB 531.5 kB/s eta 0:00:00
Requirement already satisfied: six>=1.9.0 in d:\software_install\anaconda3\lib\site-packages (from python-engineio=
=3.14) (1.11.0)
Installing collected packages: python-engineioAttempting uninstall: python-engineioFound existing installation: python-engineio 3.6.0Uninstalling python-engineio-3.6.0:Successfully uninstalled python-engineio-3.6.0
Successfully installed python-engineio-3.14.0
最终两个包的版本就是:
python-engineio 3.14.0
python-socketio 4.6.0
开启服务端,现在开始尝试用firecamp连接 http://127.0.0.1:9000
就可以正常开启了
firecap也可以正常连接了

此时也可以与服务端进行正常的通信了

服务端收到了两次客户端发来的data

server与firecamp通信正常:

fastapi+python-socketio
# -- coding:utf-8 --import socketio
from fastapi import FastAPIsio = socketio.AsyncServer(async_mode="asgi", cors_allowed_origins="*", logger=True, engineio_logger=True
)
app = FastAPI(debug=True)
app_socketio = socketio.ASGIApp(sio)
app.mount(path="/", app=app_socketio)@sio.event
async def connect(sid, environ):print('connect ', sid)await sio.emit("Server", {'data': "Connect", 'count': 0})@sio.on('message')
async def my_message(sid, data):print('message ', data)await sio.emit("message", {'data': "message" + data})@sio.event
async def disconnect(sid):print('disconnect ', sid)@sio.event
async def error(sid):print('error ', sid)@app.get("/ss")
async def root():return {"message": "Hello World"}if __name__ == '__main__':import uvicornimport osname_app = os.path.splitext(os.path.basename(__file__))[0]uvicorn.run(app=f"{name_app}:app", host="127.0.0.1", port=5008, reload=True, debug=True)
firecamp端:

服务端:

先mark一下,在这里走了不少的弯路,悟性太差,还需加油~~~~
相关文章:
【python】python-socketio+firecamp使用踩坑指南
server.py: import eventlet import asyncioeventlet.monkey_patch()import socketio import eventlet.wsgisio socketio.Server(async_modeeventlet, cors_allowed_origins*) # 指明在evenlet模式下sio.event def connect(sid, environ):print(f"connect, sid{sid}, e…...
【OJ比赛日历】快周末了,不来一场比赛吗? #03.04-03.10 #12场
CompHub 实时聚合多平台的数据类(Kaggle、天池…)和OJ类(Leetcode、牛客…)比赛。本账号同时会推送最新的比赛消息,欢迎关注!更多比赛信息见 CompHub主页 或 点击文末阅读原文以下信息仅供参考,以比赛官网为准目录2023-03-04&…...
C++11:继承
目录 继承的基本概念 继承方式 基类和派生类对象赋值转换/切片 继承中的作用域 派生类的四个成员函数: 构造函数 拷贝构造函数 赋值重载 析构函数 静态成员 继承与友元 多继承 菱形继承 多继承的指针偏移问题 组合 继承的基本概念 继承出现的契机是某一…...
【蓝桥杯试题】递归实现排列型枚举
💃🏼 本人简介:男 👶🏼 年龄:18 🤞 作者:那就叫我亮亮叭 📕 专栏:蓝桥杯试题 文章目录1. 题目描述2. 代码展示法一:dfs法二:next_perm…...
入职字节测试岗外包一个月,我离职了...
有一种打工人的羡慕,叫做“大厂”。真是年少不知大厂香,错把青春插稻秧。但是,在深圳有一群比大厂员工更庞大的群体,他们顶着大厂的“名”,做着大厂的工作,还可以享受大厂的伙食,却没有大厂的“…...
weak学习入门-01
作用:集中在特征提取、算法选择和参数调优上 本篇几乎是汇总了大佬的参考 官网https://www.cs.waikato.ac.nz/ml/weka 大佬的入门教程:初试weka数据挖掘 - 加拿大小哥哥 - 博客园 (cnblogs.com) 参考书:数据挖掘实用机器学习技术(原书第2版)...
线程池中shutdown()和shutdownNow()方法的区别
线程池中shutdown()和shutdownNow()方法的区别 一般情况下,当我们频繁的使用线程的时候,为了节约资源快速响应需求,我们都会考虑使用线程池,线程池使用完毕都会想着关闭,关闭的时候一般情况下会用到shutdown和shutdow…...
高可用/性能
文章目录1.数据库系统架构发展(1)单库架构(2)主备架构(3)主从架构2.主从复制主从同步配置主从复制模式(1)异步复制(2)半同步复制(3)全…...
PriorityQueues优先队列
优先队列优先队列(priority queue)是计算机科学中的一类抽象数据类型。优先队列中的每个元素都有各自的优先级,优先级最高的元素最先得到服务;优先级相同的元素按照其在优先队列中的顺序得到服务。优先队列通常使用“堆”…...
arm 堆栈
先转一篇 stm32 堆和栈(stm32 Heap & Stack)【worldsing笔记】_stm32堆栈_slj_win的博客-CSDN博客 关于堆和栈已经是程序员的一个月经话题,大部分有是基于os层来聊的。 那么,在赤裸裸的单片机下的堆和栈是什么样的分布呢?以下是网摘&…...
leetcode-面试题 05.02. Binary Number to String LCCI
Description Given a real number between 0 and 1 (e.g., 0.72) that is passed in as a double, print the binary representation. If the number cannot be represented accurately in binary with at most 32 characters, print “ERROR”. Example1: Input: 0.625Outpu…...
C语言函数阐述
C 函数 函数是一组一起执行一个任务的语句。每个 C 程序都至少有一个函数,即主函数 main() ,所有简单的程序都可以定义其他额外的函数。 您可以把代码划分到不同的函数中。如何划分代码到不同的函数中是由您来决定的,但在逻辑上,…...
二叉树——把二叉搜索树转换为累加树
538. 把二叉搜索树转换为累加树 链接 给出二叉 搜索 树的根节点,该树的节点值各不相同,请你将其转换为累加树(Greater Sum Tree),使每个节点 node 的新值等于原树中大于或等于 node.val 的值之和。 提醒一下…...
Java使用DFA算法实现敏感词过滤
1 前言敏感词过滤就是你在项目中输入某些字(比如输入xxoo相关的文字时)时要能检测出来,很多项目中都会有一个敏感词管理模块,在敏感词管理模块中你可以加入敏感词,然后根据加入的敏感词去过滤输入内容中的敏感词并进行…...
UG NX二次开发(C#)-外挂 - 配置文件说明(.men文件/.rtb文件/.trb文件)
文章目录 1、前言2、UG NX菜单说明2.1UG NX的Ribbon样式说明2.2 UG NX的Ribbon配置文件3、外挂的加载配置文件说明3.1 创建配置文件夹3.2 填写.men文件3.2 填写.rtb文件3.2 填写.tbr文件4、将外挂加载到UG NX菜单中5、重启UG NX,就可以实现外挂加载了。1、前言 UG NX二次开发…...
Web3中文|日本元宇宙经济“狂飙”
2月27日,三菱、富士通和其它科技公司发布关于建立“日本元宇宙经济区”的协议,表示将联手从角色扮演游戏的角度创建开放的元宇宙基础设施,以推动日本的Web3战略。据了解,日本一直在努力将Web3技术纳入其国家议程,去年1…...
@Autowired和@Resource到底有什么区别
Autowired 和 Resource 都是 Spring/Spring Boot 项目中,用来进行依赖注入的注解。它们都提供了将依赖对象注入到当前对象的功能,但二者却有众多不同,并且这也是常见的面试题之一,所以我们今天就来盘它。 Autowired 和 Resource 的…...
2023年最新阿里云服务器价格表出炉(精准收费标准及配置价格表)
阿里云在全球率先宣布了基于 Intel Ice Lake 处理器的第七代云服务器ECS,性能提升的同时降低了报价,性价比更高了。进入2023年阿里云服务器价格依然是大家关心的问题,事实上阿里云服务器租用价格和最新收费标准都可以通过官方云服务器计算器来…...
ElasticSearch - SpringBoot整合ES实现文档的增删改操作
文章目录1. ElasticSearch和kibana的安装和配置2. SpringBoot 项目环境搭建3. 创建索引4. 索引文档5. 更新文档6. 删除文档https://www.elastic.co/guide/en/elasticsearch/reference/current/search-your-data.htmlhttps://www.elastic.co/guide/cn/elasticsearch/guide/curre…...
嵌入式 LVGL移植到STM32F4
目录 LVGL简介 1、特点 2、LVGL的硬件要求 3、相关网站 4、LVGL源码下载 5、LVGL移植要求 5.1 移植过程-添加源码 2、更改接口文件 3、显示实现 4、添加外部中文字体的方法 5、编译下载后有几种情况 6、调用显示 6、GUI-Guider使用 6.1 安装软件 6.2 使用…...
重新定义室内人员定位:高精度、无感化、连续化——镜像视界引领定位范式革新
重新定义室内人员定位:高精度、无感化、连续化——镜像视界引领定位范式革新长期以来,室内人员定位行业陷入“精度不足、有感知负担、轨迹断链”的困境,传统定位方案要么依赖佩戴设备、体验不佳,要么定位模糊、无法连续追踪&#…...
复旦北大:Harness也能Agentic自进化了
Coding Agent 的性能不仅取决于底层大模型,更取决于包围它的 Harness(系统提示、工具、中间件、记忆等)。复旦&北大提出 AHE(Agentic Harness Engineering),通过组件可观测性、经验可观测性、决策可观测…...
OpenSpeedy:免费开源的终极游戏加速工具完全指南
OpenSpeedy:免费开源的终极游戏加速工具完全指南 【免费下载链接】OpenSpeedy 🎮 An open-source game speed modifier. 项目地址: https://gitcode.com/gh_mirrors/op/OpenSpeedy 你是否曾经遇到过游戏运行卡顿、帧率不稳定的问题?或…...
ThinkBook 16+ Win10蓝屏别慌!手把手教你用WinDbg分析DRIVER_IRQL_NOT_LESS_OR_EQUAL错误
ThinkBook 16 Win10蓝屏终极排查指南:从DRIVER_IRQL_NOT_LESS_OR_EQUAL到系统稳定的全流程解析 当ThinkBook 16在Win10系统下突然蓝屏,屏幕上赫然显示"DRIVER_IRQL_NOT_LESS_OR_EQUAL"时,大多数用户的第一反应往往是重启电脑并祈祷…...
Samba 完全指南:跨平台文件共享的利器
Samba 完全指南:跨平台文件共享的利器 文章目录Samba 完全指南:跨平台文件共享的利器1. 引言2. Samba 概述2.1 什么是 Samba?2.2 核心功能3. Samba 的工作原理3.1 SMB/CIFS 协议3.2 核心守护进程3.3 工作流程4. 安装与基础配置4.1 安装 Samba…...
别再手动调平了!用Halcon的`fit_surface_first_order`一键搞定倾斜表面矫正
工业视觉中的智能平面矫正:Halcon高阶算子实战解析 在PCB板检测、材料厚度分析等工业视觉场景中,样本倾斜是影响测量精度的头号杀手。传统的手动调平方法不仅效率低下,还容易引入人为误差。Halcon的fit_surface_first_order算子配合gen_imag…...
终极Anno 1800模组加载器:5分钟完成安装配置的完整指南
终极Anno 1800模组加载器:5分钟完成安装配置的完整指南 【免费下载链接】anno1800-mod-loader The one and only mod loader for Anno 1800, supports loading of unpacked RDA files, XML merging and Python mods. 项目地址: https://gitcode.com/gh_mirrors/an…...
终极指南:如何构建流畅的Android应用引导页面(AppIntro)
终极指南:如何构建流畅的Android应用引导页面(AppIntro) 【免费下载链接】AppIntro Make a cool intro for your Android app. 项目地址: https://gitcode.com/gh_mirrors/ap/AppIntro AppIntro是一个强大的Android库,专为…...
别再问项目了!这5个嵌入式开源宝藏(MultiButton/EasyLogger等)够你玩半年
5个嵌入式开源宝藏:从新手到高手的实战进阶指南 每次在技术论坛看到"求推荐嵌入式项目"的帖子,我都会想起自己刚入门时的迷茫。市面上教程虽多,但要么过于简单缺乏实战价值,要么复杂度太高让人望而生畏。经过多年项目积…...
Vivado里用DataMover IP核搬数据,我踩过的那些坑(附AXI转AXIS桥接代码)
Vivado中DataMover IP核实战避坑指南:从协议转换到调试技巧 第一次在Vivado项目中使用DataMover IP核进行数据搬运时,我本以为按照官方文档就能轻松搞定,结果却遭遇了各种意想不到的问题。从CMD接口位宽不匹配到tready信号异常,再…...
