Closed jdalmasso1 closed 1 year ago
The controller python code is:
import asyncio
import websockets
import usp_example_pb2
async def handle_message(websocket, path):
async for data in websocket:
# Parse the incoming message
msg = usp_pb2.Message()
msg.ParseFromString(data)
# Check if the message is a Get request
if msg.header.msg_type == usp_pb2.Header.GET:
# Process the Get request
get_resp = usp_pb2.Message()
get_resp.header.msg_id = msg.header.msg_id
get_resp.header.msg_type = usp_pb2.Header.GET_RESP
get_resp.header.msg_version = "1.0"
get_resp.header.encryption_mode = usp_pb2.Header.PLAINTEXT
get_resp.body.response.get_resp.value = "Hello, world!"
await websocket.send(get_resp.SerializeToString())
start_server = websockets.serve(handle_message, "10.0.2.20", 8080)
asyncio.get_event_loop().run_until_complete(start_server)
asyncio.get_event_loop().run_forever()
The library usp_example_pb2 is generated by protoc the following file:
// usp_example.proto
syntax = "proto3";
message DeviceInfoRequest {
string token = 1;
}
message DeviceInfoResponse {
string device_id = 1;
string firmware_version = 2;
string model = 3;
}
It looks like the python library does not like the Sec-WebSocket-Extensions header ("invalid quoted header content") and most likely this is because it is requiring the string to be escaped. But in the forthcoming USP 1.3 specification, the requirement for the client to send the Sec-WebSocket-Extensions header is being deprecated anyway, so I think the simplest fix is to comment out the call to AddWsclientUspExtension() in wsclient.c, so that OBUSPA doesn't send the Sec-WebSocket-Extensions header. Please try this. We will be updating OBUSPA to USP 1.3 after it is released, removing the Sec-WebSocket-Extensions header officially from the OBUSPA codebase.
Closing as this appears to have addressed the issue. Please re-open if there are still issues.
Hi everyone.
I'm trying to connect the OB-USP-Agent to a python controller that is working and listening with WebSockets. The WebSockets Server is in 10.0.2.20:8080, while the OBUSPA is running on another VM in the same LAN (10.0.2.10). Ping between both is OK.
The factory_reset_example.txt is:
The error on the agent side is:
When capturing with Wireshark, I see this:
Can you help with this issue?