Hi.
I have temperature sensors that have an API using WebSocket protocol (wss).
I imported the library https://pypi.org/project/websocket-client/ to create a WebSocket client.
My script for establishing a connection:
import websocket
ws = websocket.WebSocket()
ws.connect("wss://echo.websocket.org")
ws.send("Hello, Server")
print(ws.recv())
If I use “ws://” connection created, but if I use “wss://” i get error:
Traceback (most recent call last):
File "<input>", line 4, in <module>
File "C:\Users\User\.ignition\cache\gwlocalhost_8088\C0\pylib\websocket\_core.py", line 248, in connect
self.sock, addrs = connect(url, self.sock_opt, proxy_info(**options),
File "C:\Users\User\.ignition\cache\gwlocalhost_8088\C0\pylib\websocket\_http.py", line 126, in connect
sock = _ssl_socket(sock, options.sslopt, hostname)
File "C:\Users\User\.ignition\cache\gwlocalhost_8088\C0\pylib\websocket\_http.py", line 266, in _ssl_socket
sock = ssl.wrap_socket(sock, **sslopt)
File "C:\Users\User\.ignition\cache\gwlocalhost_8088\C0\pylib\_socket.py", line 382, in handle_exception
return method_or_function(*args, **kwargs)
File "C:\Users\User\.ignition\cache\gwlocalhost_8088\C0\pylib\_socket.py", line 382, in handle_exception
return method_or_function(*args, **kwargs)
File "C:\Users\User\.ignition\cache\gwlocalhost_8088\C0\pylib\ssl.py", line 904, in wrap_socket
return SSLSocket(
File "C:\Users\User\.ignition\cache\gwlocalhost_8088\C0\pylib\ssl.py", line 575, in __init__
self.do_handshake()
File "C:\Users\User\.ignition\cache\gwlocalhost_8088\C0\pylib\ssl.py", line 691, in do_handshake
self._sock._handle_channel_future(self._handshake_future, "SSL handshake")
File "C:\Users\User\.ignition\cache\gwlocalhost_8088\C0\pylib\_socket.py", line 384, in handle_exception
raise _map_exception(jlx)
_socket.SSLError: [Errno 1] certificate verify failed (java.security.cert.CertificateException: certificate verify failed)
Please tell me what I can do to fix this.
Maybe there are some other tools for working with websocket in Ignition.
On the forum I read that you can use the jetty java library, But I never worked with this.
I would be grateful for any help.