Skip to content

Commit dfe9143

Browse files
authored
Merge pull request #214 from jlas/master
Connection is already closed: send ping based on time elapsed
2 parents 2b29fa0 + ed6a3e0 commit dfe9143

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

gdax/websocket_client.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,11 @@ def _connect(self):
8484
def _listen(self):
8585
while not self.stop:
8686
try:
87-
if int(time.time() % 30) == 0:
87+
start_t = 0
88+
if time.time() - start_t >= 30:
8889
# Set a 30 second ping to keep connection alive
8990
self.ws.ping("keepalive")
91+
start_t = time.time()
9092
data = self.ws.recv()
9193
msg = json.loads(data)
9294
except ValueError as e:

0 commit comments

Comments
 (0)