Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove ping text from sendPing instead of binary payload from websocket #189

Closed
wants to merge 9 commits into from
1 change: 1 addition & 0 deletions dev_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ responses>=0.12.1
pytest-cov>=2.10.1
flake8>=3.8.4, <= 4.0.1
mock>=3.0.5
urllib3<2.0
4 changes: 0 additions & 4 deletions kiteconnect/ticker.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class KiteTickerClientProtocol(WebSocketClientProtocol):
PING_INTERVAL = 2.5
KEEPALIVE_INTERVAL = 5

_ping_message = ""
_next_ping = None
_next_pong_check = None
_last_pong_time = None
Expand Down Expand Up @@ -107,14 +106,11 @@ def onPong(self, response): # noqa
def _loop_ping(self): # noqa
"""Start a ping loop where it sends ping message every X seconds."""
if self.factory.debug:
log.debug("ping => {}".format(self._ping_message))
if self._last_ping_time:
log.debug("last ping was {} seconds back.".format(time.time() - self._last_ping_time))

# Set current time as last ping time
self._last_ping_time = time.time()
# Send a ping message to server
self.sendPing(self._ping_message)

# Call self after X seconds
self._next_ping = self.factory.reactor.callLater(self.PING_INTERVAL, self._loop_ping)
Expand Down
Loading