Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make MAX_LINE configurable #1471

Closed
dangeReis opened this issue Jun 6, 2024 · 5 comments
Closed

Make MAX_LINE configurable #1471

dangeReis opened this issue Jun 6, 2024 · 5 comments

Comments

@dangeReis
Copy link

We currently have a cookie line header of 8718 characters, which is larger than MAX_LINE setting of 8192. Can this either be bumped up to 16K, or better yet be configurable in the ENV? Also it would be nice if a proper error message was returned, we are currently getting

HTTP/1.1 400 Bad Request
Date: Thu, 06 Jun 2024 16:09:28 GMT
Content-Type: text/plain
Content-Length: 77
Connection: keep-alive

Failed to open a WebSocket connection: did not receive a valid HTTP request.

Which isn't very helpful.

https://github.com/python-websockets/websockets/blame/01195322d2620a44039b716cb93c108c2ca9b6b9/src/websockets/legacy/http.py#L14

@teamclouday
Copy link

Yea I'm facing the same issue. The cookie line is longer than MAX_LINE.
What's weird is that I configured withCredentials: false in socketio client but it still gets sent in the header. I also tried to configure fastapi middleware but the cookie wasn't found in the request. Not sure if this is an issue with websockets or socketio

@aaugustin
Copy link
Member

The best answer I have right now is still this one: #1243 (comment)

@aaugustin
Copy link
Member

I just made a change that gives you a slightly better error message in that case:

Failed to open a WebSocket connection: did not receive a valid HTTP request; line too long.

@aaugustin
Copy link
Member

I'm going to make it configurable via an environment variable.

@aaugustin
Copy link
Member

Fixed in bbb3161.

Please be aware that, if you are currently monkey-patching MAX_LINE, that will break in version 13.0. You will have to set the WEBSOCKETS_MAX_LINE_LENGTH environment variable instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants