From 167d96b6ba24b89c168a61db4b6744edb267cfe8 Mon Sep 17 00:00:00 2001 From: wsy182 <2392948297@qq.com> Date: Mon, 24 Nov 2025 10:23:46 +0800 Subject: [PATCH] =?UTF-8?q?feat(wits):=20=E6=B7=BB=E5=8A=A0WITS=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=A8=A1=E6=8B=9F=E5=8F=91=E9=80=81=E8=84=9A=E6=9C=AC?= =?UTF-8?q?-=20=E5=AE=9E=E7=8E=B0=E9=9A=8F=E6=9C=BA=E7=94=9F=E6=88=90WITS?= =?UTF-8?q?=E5=8D=8F=E8=AE=AE=E6=95=B0=E6=8D=AE=E5=8A=9F=E8=83=BD=20-=20?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=95=B4=E6=95=B0=E5=92=8C=E6=B5=AE=E7=82=B9?= =?UTF-8?q?=E6=95=B0=E4=B8=A4=E7=A7=8D=E6=95=B0=E6=8D=AE=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=20-=20=E9=85=8D=E7=BD=AE=E7=9B=AE=E6=A0=87=E4=B8=BB=E6=9C=BA?= =?UTF-8?q?=E5=92=8C=E7=AB=AF=E5=8F=A3=E8=BF=9B=E8=A1=8CTCP=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=20-=20=E5=BE=AA=E7=8E=AF=E5=8F=91=E9=80=81=E9=A2=84?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E7=9A=84WITS=E5=AD=97=E6=AE=B5=E7=A0=81=20-?= =?UTF-8?q?=20=E6=B7=BB=E5=8A=A0=E5=8F=91=E9=80=81=E9=97=B4=E9=9A=94?= =?UTF-8?q?=E6=8E=A7=E5=88=B6=E5=92=8C=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86?= =?UTF-8?q?=E6=9C=BA=E5=88=B6-=20=E6=8F=90=E4=BE=9B=E5=91=BD=E4=BB=A4?= =?UTF-8?q?=E8=A1=8C=E5=85=A5=E5=8F=A3=E7=9B=B4=E6=8E=A5=E8=BF=90=E8=A1=8C?= =?UTF-8?q?=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test_websocket.py | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/test_websocket.py b/test_websocket.py index 62f31ac..b534ab8 100644 --- a/test_websocket.py +++ b/test_websocket.py @@ -1,28 +1,20 @@ import ssl import websocket -URL = "ws://192.168.1.8:8084/ws" # 注意走 443,不要再连 8080 了 -# 如果你的 WS 路径是 /ws/,就写成上面这样;若是别的路径自己改 +# URL = "ws://192.168.1.202:9100/well-tool-test-system/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") +URL = "wss://192.168.1.87/ws/" +ws = websocket.WebSocketApp( + URL, + on_open=lambda ws: print("连接成功"), + on_message=lambda ws, msg: print("消息:", msg), + on_error=lambda ws, err: print("错误:", err), + on_close=lambda ws, code, reason: print("关闭:", code, reason), +) -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={ +ws.run_forever( + sslopt={ "cert_reqs": ssl.CERT_NONE, "check_hostname": False, - }) \ No newline at end of file + } +)