This commit is contained in:
Olivier Martin 2025-02-07 12:27:10 +08:00 committed by GitHub
commit 4646e3867d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -284,11 +284,18 @@ class WebSocketProtocol(WebSocketServerProtocol):
self.duration() > self.server.websocket_timeout
and self.server.websocket_timeout >= 0
):
logger.warning(
"WebSocket %s took too long and was killed.", self.client_addr
)
self.serverClose()
# Ping check
# If we're still connecting, deny the connection
if self.state == self.STATE_CONNECTING:
if self.duration() > self.server.websocket_connect_timeout:
logger.warning(
"WebSocket %s connection took too long and was killed.",
self.client_addr,
)
self.serverReject()
elif self.state == self.STATE_OPEN:
if (time.time() - self.last_ping) > self.server.ping_interval: