-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_socket.py
More file actions
30 lines (21 loc) · 839 Bytes
/
test_socket.py
File metadata and controls
30 lines (21 loc) · 839 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"""
Copyright © 2024 Acme Software LLC. All rights reserved.
This software is proprietary and confidential. Unauthorized copying, distribution,
modification, or use of this software, in whole or in part, is strictly prohibited
without prior written permission from Acme Software LLC.
For inquiries, contact: legal@acmesoftware.com
"""
from asyncio import run
from websockets import connect
async def test_websocket():
uri = "ws://localhost:8000/ws/incidents"
headers = {"Authorization": "Bearer test"}
try:
async with connect(uri, additional_headers=headers) as websocket:
print("Connected to WebSocket server")
while True:
message = await websocket.recv()
print(f"Incident: {message}")
except Exception as e:
print(e)
run(test_websocket())