File tree Expand file tree Collapse file tree 1 file changed +5
-26
lines changed
internal_filesystem/apps/com.example.btcticker/assets Expand file tree Collapse file tree 1 file changed +5
-26
lines changed Original file line number Diff line number Diff line change 1- import sys
21import ssl
3-
4- # ruff: noqa: E402
5- sys .path .insert (0 , "." )
62import aiohttp
73import asyncio
84
9- try :
10- URL = sys .argv [1 ] # expects a websocket echo server
11- except Exception :
12- # URL = "ws://echo.websocket.events" # also works
13- URL = "wss://echo.websocket.events"
14-
15-
16- sslctx = False
17-
18- if URL .startswith ("wss:" ):
19- try :
20- sslctx = ssl .SSLContext (ssl .PROTOCOL_TLS_CLIENT )
21- sslctx .verify_mode = ssl .CERT_NONE
22- #sslctx.verify_mode = ssl.CERT_REQUIRED # doesn't work because OSError: (-30336, 'MBEDTLS_ERR_SSL_CA_CHAIN_REQUIRED')
23- except Exception :
24- pass
25-
5+ sslctx = ssl .SSLContext (ssl .PROTOCOL_TLS_CLIENT )
6+ sslctx .verify_mode = ssl .CERT_NONE
7+ #sslctx.verify_mode = ssl.CERT_REQUIRED # doesn't work because OSError: (-30336, 'MBEDTLS_ERR_SSL_CA_CHAIN_REQUIRED')
268
279async def ws_test_echo (session ):
28- async with session .ws_connect (URL , ssl = sslctx ) as ws :
10+ async with session .ws_connect ("wss://echo.websocket.events" , ssl = sslctx ) as ws :
2911 await ws .send_str ("hello world!\r \n " )
3012 async for msg in ws :
3113 if msg .type == aiohttp .WSMsgType .TEXT :
@@ -35,11 +17,8 @@ async def ws_test_echo(session):
3517 await ws .send_str ("close\r \n " )
3618 await ws .close ()
3719
38-
3920async def main ():
4021 async with aiohttp .ClientSession () as session :
4122 await ws_test_echo (session )
4223
43-
44- if __name__ == "__main__" :
45- asyncio .run (main ())
24+ asyncio .run (main ())
You can’t perform that action at this time.
0 commit comments