openpi icon indicating copy to clipboard operation
openpi copied to clipboard

Client failed to connect: websockets.exceptions.InvalidMessage: did not receive a valid HTTP response

Open TH-666 opened this issue 4 months ago • 3 comments

I'm trying to deploy the OpenPI inference server by following the official instructions. The server seems to start correctly, but when I run the client, it fails with the following error: websockets.exceptions.InvalidMessage: did not receive a valid HTTP response

Steps to reproduce

I ran the server using:

python scripts/serve_policy.py --policy.config=pi0_fast_droid --policy.dir=/path/to/checkpoint (The server prints: server listening on 0.0.0.0:8000)

Then I ran the client:

python examples/simple_client/main.py --env=DROID The client failed with:

websockets.exceptions.InvalidMessage: did not receive a valid HTTP response

python examples/simple_client/main.py --env=DROID INFO:root:Waiting for server at ws://10.67.185.12:8000... Traceback (most recent call last): File "/root/miniconda/envs/openpi/lib/python3.11/site-packages/websockets/http11.py", line 241, in parse status_line = yield from parse_line(read_line) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/miniconda/envs/openpi/lib/python3.11/site-packages/websockets/http11.py", line 309, in parse_line line = yield from read_line(MAX_LINE_LENGTH) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/miniconda/envs/openpi/lib/python3.11/site-packages/websockets/streams.py", line 46, in read_line raise EOFError(f"stream ends after {p} bytes, before end of line") EOFError: stream ends after 0 bytes, before end of line

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/root/miniconda/envs/openpi/lib/python3.11/site-packages/websockets/client.py", line 301, in parse response = yield from Response.parse( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/miniconda/envs/openpi/lib/python3.11/site-packages/websockets/http11.py", line 243, in parse raise EOFError("connection closed while reading HTTP status line") from exc EOFError: connection closed while reading HTTP status line

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/root/paddlejob/workspace/openpi/examples/simple_client/main.py", line 189, in main(tyro.cli(Args)) File "/root/paddlejob/workspace/openpi/examples/simple_client/main.py", line 127, in main policy = _websocket_client_policy.WebsocketClientPolicy( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/paddlejob/workspace/robot/openpi/packages/openpi-client/src/openpi_client/websocket_client_policy.py", line 24, in init self._ws, self._server_metadata = self._wait_for_server() ^^^^^^^^^^^^^^^^^^^^^^^ File "/root/paddlejob/workspace/robot/openpi/packages/openpi-client/src/openpi_client/websocket_client_policy.py", line 34, in _wait_for_server conn = websockets.sync.client.connect( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/miniconda/envs/openpi/lib/python3.11/site-packages/websockets/sync/client.py", line 378, in connect connection.handshake( File "/root/miniconda/envs/openpi/lib/python3.11/site-packages/websockets/sync/client.py", line 101, in handshake raise self.protocol.handshake_exc websockets.exceptions.InvalidMessage: did not receive a valid HTTP response

TH-666 avatar Jul 18 '25 12:07 TH-666