Skip to content

Commit 4005080

Browse files
[PR #10564/a59e74b7 backport][3.11] Log offending websocket client address when no protocols overlap (#10575)
**This is a backport of PR #10564 as merged into master (a59e74b).** <!-- Thank you for your contribution! --> ## What do these changes do? Logs the remote address of a WebSocket client that has no overlapping protocols ## Are there changes in behavior for the user? Which client has the problem should be a bit more discoverable ## Is it a substantial burden for the maintainers to support this? no ## Related issue number closes #10563 Co-authored-by: J. Nick Koston <[email protected]>
1 parent 6ae2570 commit 4005080

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

CHANGES/10564.feature.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Improved logging on non-overlapping WebSocket client protocols to include the remote address -- by :user:`bdraco`.

aiohttp/web_ws.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,8 @@ def _handshake(
252252
else:
253253
# No overlap found: Return no protocol as per spec
254254
ws_logger.warning(
255-
"Client protocols %r don’t overlap server-known ones %r",
255+
"%s: Client protocols %r don’t overlap server-known ones %r",
256+
request.remote,
256257
req_protocols,
257258
self._protocols,
258259
)

tests/test_websocket_handshake.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ async def test_handshake_protocol_unsupported(caplog) -> None:
174174

175175
assert (
176176
caplog.records[-1].msg
177-
== "Client protocols %r don’t overlap server-known ones %r"
177+
== "%s: Client protocols %r don’t overlap server-known ones %r"
178178
)
179179
assert ws.ws_protocol is None
180180

0 commit comments

Comments
 (0)