-
-
Notifications
You must be signed in to change notification settings - Fork 540
Non-websocket responses created with process_response log "connection rejected (200 OK)" #1606
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
Comments
I'm happy to do a PR for this; is there a particular approach you'd prefer me to take with it? |
I've been thinking about this and still don't have a good plan to achieve what you'd like that also works for everyone else :-( Logging at the INFO level when websockets opens or rejects the WebSocket connection is uncontroversial. The question here is about what to log when a user-provided Currently websockets logs a line at the INFO level for any WebSocket handshake or HTTP request that receives a WebSocket handshake or HTTP response without error, regardless of where the response comes from. That's a consistent behavior. I understand that you don't feel the need to log requests to your health check endpoint. However, I can also imagine someone being confused by not getting logs for requests to their health check endpoint. Furthermore, I don't think it's possible to draw a line between " If we stick to logging one line for each request/response, then we can use more generic wording to avoid logging "connection rejected" for successful health checks. Ideally we find a wording that covers all these cases and rely on the HTTP code to help the user figure out what's happening:
|
If the response is considered a failure, why wouldn't it be a 4xx response?
It could be something like:
Related: we could potentially tidy up this log to be more like an access log, with timestamp, path, IP, status_code, and an indication of whether a websocket connection was initiated. |
Scenario
I have a /healthz endpoint on my websocket server, used as a kubernetes health check.
What I expected to happen
If the websocket connection upgrade headers aren't present, then no "connection rejection" message needs be send.
Relevant code
This code from
ServerProtocol.send_response()
seems to be the source.I expect we could change the second block to only send a message if a boolean websocket_requested parameter was true. That would mean change the method signature, which is a bit of a pain.
Alternatively, we could avoid showing a rejection message for any 200-399 response.
Should I raise a PR?
The text was updated successfully, but these errors were encountered: