I need to set up a websocket connection to a Vivotek IB9387-HT-A web camera.
The javascript connection works. When connecting via python I get the response:
"websockets.exceptions.InvalidStatusCode: server rejected WebSocket connection: HTTP 401"
import asyncio
import websockets
async def websocket_example():
uri = "ws://root:[email protected]:80/ws/vca?data=meta,event"
try:
async with websockets.connect(uri) as websocket:
# Send a message to the server
message_to_send = "Hello, WebSocket!"
await websocket.send(message_to_send)
print(f"Sent: {message_to_send}")
# Receive a message from the server
received_message = await websocket.recv()
print(f"Received: {received_message}")
except websockets.exceptions.ConnectionClosed as e:
print(f"Connection closed: {e}")
if __name__ == "__main__":
asyncio.get_event_loop().run_until_complete(websocket_example())