Actually, I just tried this code and it just worked. Websocket connected!What errors do you see?I have websockets installed on my raspberry pi but I am unable to establish a connection.
pip show websocket-clientThe following python code yields errors:Code:
pi@popcamera:~ $ pip show websocket-clientName: websocket-clientVersion: 1.2.3Summary: WebSocket client for Python with low level API optionsHome-page: https://github.com/websocket-client/websocket-client.gitAuthor: lirisAuthor-email: liris.pp@gmail.comLicense: Apache-2.0Location: /usr/lib/python3/dist-packagesRequires: Required-by:
Code:
import websocketimport base64# WebSocket setupws_url = "ws://localhost:7071" # Adjust the WebSocket server URL if neededws = websocket.create_connection(ws_url)
Have you googled the error messages to find a cause and perhaps a solution?
Code:
import websocketws_url = "ws://localhost:7071"try: ws = websocket.create_connection(ws_url) print("WebSocket connection established")except Exception as e: print("Failed to connect to WebSocket:", e) sys.exit(1)
Statistics: Posted by MRV — Thu Nov 07, 2024 3:59 pm