21 lines
490 B
Python
21 lines
490 B
Python
import ssl
|
|
import websocket
|
|
|
|
# URL = "ws://192.168.1.202:9100/well-tool-test-system/ws/"
|
|
|
|
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),
|
|
)
|
|
|
|
ws.run_forever(
|
|
sslopt={
|
|
"cert_reqs": ssl.CERT_NONE,
|
|
"check_hostname": False,
|
|
}
|
|
)
|