Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 1247

Python • Websockets = :-(

$
0
0
I have websockets installed on my raspberry pi but I am unable to establish a connection.

pip show websocket-client

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: 
The following python code yields errors:

Code:

import websocketimport base64# WebSocket setupws_url = "ws://localhost:7071"  # Adjust the WebSocket server URL if neededws = websocket.create_connection(ws_url)

I've replaced "local host" with my ip (hostname -I) but still get errors:

Code:

pi@popcamera:/var/www/html $ python3 view.pyTraceback (most recent call last):  File "/var/www/html/view.py", line 16, in <module>    ws = websocket.create_connection(ws_url)         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/usr/lib/python3/dist-packages/websocket/_core.py", line 606, in create_connection    websock.connect(url, **options)  File "/usr/lib/python3/dist-packages/websocket/_core.py", line 249, in connect    self.sock, addrs = connect(url, self.sock_opt, proxy_info(**options),                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/usr/lib/python3/dist-packages/websocket/_http.py", line 130, in connect    sock = _open_socket(addrinfo_list, options.sockopt, options.timeout)           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/usr/lib/python3/dist-packages/websocket/_http.py", line 208, in _open_socket    raise err  File "/usr/lib/python3/dist-packages/websocket/_http.py", line 185, in _open_socket    sock.connect(address)ConnectionRefusedError: [Errno 111] Connection refused

Statistics: Posted by MRV — Thu Nov 07, 2024 2:59 pm



Viewing all articles
Browse latest Browse all 1247

Trending Articles