Files
py-test/test_websocket.py
wsy182 25008d7845 feat(test): 添加WebSocket连接测试脚本
- 新增taosTest.py文件实现TDengine数据库连接测试
- 实现创建子表、插入测试数据和查询功能
- 集成taosws库进行WebSocket数据库操作
- 更新test_websocket.py中的连接地址配置
- 添加时间戳基准和批量数据插入功能
- 实现稳定表和子表的查询对比测试
2026-03-13 17:24:34 +08:00

28 lines
887 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import ssl
import websocket
URL = "wss://192.168.1.87/ws/" # 注意走 443不要再连 8080 了
# 如果你的 WS 路径是 /ws/,就写成上面这样;若是别的路径自己改
def on_message(ws, msg): print("收到:", msg)
def on_error(ws, err): print("错误:", err)
def on_close(ws, code, reason): print("关闭:", code, reason)
def on_open(ws):
print("连接成功")
ws.send("hello server mac")
if __name__ == "__main__":
websocket.enableTrace(True)
ws = websocket.WebSocketApp(
URL,
on_open=on_open,
on_message=on_message,
on_error=on_error,
on_close=on_close,
# header=["Origin: https://192.168.1.3"] # 如后端不校验 Origin 可删
header=[] # 如后端不校验 Origin 可删
)
ws.run_forever(sslopt={
"cert_reqs": ssl.CERT_NONE,
"check_hostname": False,
})