update websocket examples

This commit is contained in:
Thomas Farstrike
2025-05-18 17:17:35 +02:00
parent 2f0546e0d3
commit ba9e55e48c
2 changed files with 5 additions and 3 deletions
+2 -2
View File
@@ -9,8 +9,8 @@ host = 'ws.postman-echo.com'
port = 443
handshake_path = '/raw'
# Option: echo.websocket.events (unreliable)
# host = 'echo.websocket.events'
# handshake_path = '/'
#host = 'echo.websocket.events'
#handshake_path = '/'
try:
addr_info = socket.getaddrinfo(host, port)[0][-1]
@@ -15,7 +15,8 @@ import asyncio
try:
URL = sys.argv[1] # expects a websocket echo server
except Exception:
URL = "ws://echo.websocket.events"
# URL = "ws://echo.websocket.events" # also works
URL = "wss://echo.websocket.events"
sslctx = False
@@ -24,6 +25,7 @@ if URL.startswith("wss:"):
try:
sslctx = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
sslctx.verify_mode = ssl.CERT_NONE
#sslctx.verify_mode = ssl.CERT_REQUIRED # doesn't work because OSError: (-30336, 'MBEDTLS_ERR_SSL_CA_CHAIN_REQUIRED')
except Exception:
pass