File size: 444 Bytes
61898fa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import asyncio
import websockets
import json

async def test_ws_client():
    uri = "ws://127.0.0.1:5005/ws/echo"
    try:
        async with websockets.connect(uri) as ws:
            print('Connected to echo WS')
            await ws.send(json.dumps({"test": 1}))
            print('Received:', await ws.recv())
    except Exception as e:
        print(f'Error during test: {e}')

if __name__ == '__main__':
    asyncio.run(test_ws_client())