Skip to content

EOFError: stream ends after 0 bytes #1551

@castelo-software

Description

@castelo-software

I am running a containerized WebSocket service on Azure Container Apps, and while everything actually works, my logs get full with handshake errors, even when no requests are being sent to the server.

I'm hoping someone can help me identify which requests are failing.

The error (which is raised non-stop) is the following:

opening handshake failed
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/websockets/http11.py", line 134, in parse
    request_line = yield from parse_line(read_line)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/websockets/http11.py", line 380, in parse_line
    line = yield from read_line(MAX_LINE_LENGTH)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/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 "/usr/local/lib/python3.12/site-packages/websockets/asyncio/server.py", line 353, in conn_handler
    await connection.handshake(
  File "/usr/local/lib/python3.12/site-packages/websockets/asyncio/server.py", line 204, in handshake
    raise self.protocol.handshake_exc
  File "/usr/local/lib/python3.12/site-packages/websockets/server.py", line 551, in parse
    request = yield from Request.parse(
              ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/websockets/http11.py", line 136, in parse
    raise EOFError("connection closed while reading HTTP request line") from exc
EOFError: connection closed while reading HTTP request line

This happens before the process_request even gets the opportunity to run, so I haven't been able to log any information about the request.

Important to note, that this does not happen when the container runs locally.

The actual requests made by my client go through and work without any issues.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions