aboutsummaryrefslogtreecommitdiff
path: root/discord/gateway.py
diff options
context:
space:
mode:
Diffstat (limited to 'discord/gateway.py')
-rw-r--r--discord/gateway.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/discord/gateway.py b/discord/gateway.py
index d5ddb9eb..50104034 100644
--- a/discord/gateway.py
+++ b/discord/gateway.py
@@ -64,10 +64,11 @@ class KeepAliveHandler(threading.Thread):
self._stop_ev = threading.Event()
self._last_ack = time.time()
self._last_send = time.time()
+ self.heartbeat_timeout = ws._max_heartbeat_timeout
def run(self):
while not self._stop_ev.wait(self.interval):
- if self._last_ack + 2 * self.interval < time.time():
+ if self._last_ack + self.heartbeat_timeout < time.time():
log.warn("Shard ID %s has stopped responding to the gateway. Closing and restarting." % self.shard_id)
coro = self.ws.close(1006)
f = compat.run_coroutine_threadsafe(coro, loop=self.ws.loop)
@@ -205,6 +206,7 @@ class DiscordWebSocket(websockets.client.WebSocketClientProtocol):
ws.shard_count = client._connection.shard_count
ws.session_id = session
ws.sequence = sequence
+ ws._max_heartbeat_timeout = client._connection.heartbeat_timeout
client._connection._update_references(ws)
@@ -590,6 +592,7 @@ class DiscordVoiceWebSocket(websockets.client.WebSocketClientProtocol):
ws = yield from websockets.connect(gateway, loop=client.loop, klass=cls)
ws.gateway = gateway
ws._connection = client
+ ws._max_heartbeat_timeout = 60.0
if resume:
yield from ws.resume()