Skip to content

Commit

Permalink
Rejecting a connection isn't always a failure.
Browse files Browse the repository at this point in the history
Fix #1402.
  • Loading branch information
aaugustin committed Oct 1, 2023
1 parent adfb8d6 commit c41ce81
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/websockets/legacy/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ async def handler(self) -> None:

self.write_http_response(status, headers, body)
self.logger.info(
"connection failed (%d %s)", status.value, status.phrase
"connection rejected (%d %s)", status.value, status.phrase
)
await self.close_transport()
return
Expand Down
2 changes: 1 addition & 1 deletion src/websockets/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ def reject(
# "handshake_exc is None if and only if opening handshake succeeded."
if self.handshake_exc is None:
self.handshake_exc = InvalidStatus(response)
self.logger.info("connection failed (%d %s)", status.value, status.phrase)
self.logger.info("connection rejected (%d %s)", status.value, status.phrase)
return response

def send_response(self, response: Response) -> None:
Expand Down
4 changes: 2 additions & 2 deletions tests/legacy/test_client_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -1597,12 +1597,12 @@ async def run_client():
self.assertEqual(
[record.getMessage() for record in logs.records][4:-1],
[
"connection failed (503 Service Unavailable)",
"connection rejected (503 Service Unavailable)",
"connection closed",
"! connect failed; reconnecting in 0.0 seconds",
]
+ [
"connection failed (503 Service Unavailable)",
"connection rejected (503 Service Unavailable)",
"connection closed",
"! connect failed again; retrying in 0 seconds",
]
Expand Down

0 comments on commit c41ce81

Please sign in to comment.