Skip to content

Commit

Permalink
Send ping based on time elapsed, modulus op needs to line up exactly
Browse files Browse the repository at this point in the history
  • Loading branch information
jlas committed Dec 30, 2017
1 parent 8765d28 commit ed6a3e0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion gdax/websocket_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,11 @@ def _connect(self):
def _listen(self):
while not self.stop:
try:
if int(time.time() % 30) == 0:
start_t = 0
if time.time() - start_t >= 30:
# Set a 30 second ping to keep connection alive
self.ws.ping("keepalive")
start_t = time.time()
data = self.ws.recv()
msg = json.loads(data)
except ValueError as e:
Expand Down

0 comments on commit ed6a3e0

Please sign in to comment.