Skip to content

Commit a59e74b

Browse files
authored
Log offending websocket client address when no protocols overlap (#10564)
<!-- 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
1 parent dfbf782 commit a59e74b

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
@@ -256,7 +256,8 @@ def _handshake(
256256
else:
257257
# No overlap found: Return no protocol as per spec
258258
ws_logger.warning(
259-
"Client protocols %r don’t overlap server-known ones %r",
259+
"%s: Client protocols %r don’t overlap server-known ones %r",
260+
request.remote,
260261
req_protocols,
261262
self._protocols,
262263
)

tests/test_websocket_handshake.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ async def test_handshake_protocol_unsupported(caplog: pytest.LogCaptureFixture)
175175

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

0 commit comments

Comments
 (0)