mirror of
https://github.com/django/daphne.git
synced 2024-11-22 07:56:34 +03:00
Fixed #172: Outgoing frames do not reset ping clock (incoming does)
This commit is contained in:
parent
de0811f13e
commit
173617ad3b
|
@ -28,7 +28,7 @@ class WebSocketProtocol(WebSocketServerProtocol):
|
||||||
self.request = request
|
self.request = request
|
||||||
self.protocol_to_accept = None
|
self.protocol_to_accept = None
|
||||||
self.socket_opened = time.time()
|
self.socket_opened = time.time()
|
||||||
self.last_data = time.time()
|
self.last_ping = time.time()
|
||||||
try:
|
try:
|
||||||
# Sanitize and decode headers
|
# Sanitize and decode headers
|
||||||
self.clean_headers = []
|
self.clean_headers = []
|
||||||
|
@ -108,7 +108,7 @@ class WebSocketProtocol(WebSocketServerProtocol):
|
||||||
logger.debug("Muting incoming frame on %s", self.client_addr)
|
logger.debug("Muting incoming frame on %s", self.client_addr)
|
||||||
return
|
return
|
||||||
logger.debug("WebSocket incoming frame on %s", self.client_addr)
|
logger.debug("WebSocket incoming frame on %s", self.client_addr)
|
||||||
self.last_data = time.time()
|
self.last_ping = time.time()
|
||||||
if isBinary:
|
if isBinary:
|
||||||
self.application_queue.put_nowait({
|
self.application_queue.put_nowait({
|
||||||
"type": "websocket.receive",
|
"type": "websocket.receive",
|
||||||
|
@ -200,7 +200,6 @@ class WebSocketProtocol(WebSocketServerProtocol):
|
||||||
"""
|
"""
|
||||||
if self.state == self.STATE_CONNECTING:
|
if self.state == self.STATE_CONNECTING:
|
||||||
self.serverAccept()
|
self.serverAccept()
|
||||||
self.last_data = time.time()
|
|
||||||
logger.debug("Sent WebSocket packet to client for %s", self.client_addr)
|
logger.debug("Sent WebSocket packet to client for %s", self.client_addr)
|
||||||
if binary:
|
if binary:
|
||||||
self.sendMessage(content, binary)
|
self.sendMessage(content, binary)
|
||||||
|
@ -235,9 +234,9 @@ class WebSocketProtocol(WebSocketServerProtocol):
|
||||||
if self.duration() > self.server.websocket_connect_timeout:
|
if self.duration() > self.server.websocket_connect_timeout:
|
||||||
self.serverReject()
|
self.serverReject()
|
||||||
elif self.state == self.STATE_OPEN:
|
elif self.state == self.STATE_OPEN:
|
||||||
if (time.time() - self.last_data) > self.server.ping_interval:
|
if (time.time() - self.last_ping) > self.server.ping_interval:
|
||||||
self._sendAutoPing()
|
self._sendAutoPing()
|
||||||
self.last_data = time.time()
|
self.last_ping = time.time()
|
||||||
|
|
||||||
def __hash__(self):
|
def __hash__(self):
|
||||||
return hash(id(self))
|
return hash(id(self))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user