diff options
author | lovetox <philipp@hoerist.com> | 2020-03-26 00:59:19 +0300 |
---|---|---|
committer | lovetox <philipp@hoerist.com> | 2020-03-26 00:59:35 +0300 |
commit | 452f5eabdc9d391a9cde7f19f178157e1c05751f (patch) | |
tree | 85c374247daba0baeeecb272b525879caab4785b /nbxmpp/client.py | |
parent | 74cf3a1eceacf0935bd9a2686985127039700f62 (diff) |
Client: Fix various things with pings
- Remove ping callback after disconnect
- Address ping correctly to the domain instead of bare jid
Diffstat (limited to 'nbxmpp/client.py')
-rw-r--r-- | nbxmpp/client.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/nbxmpp/client.py b/nbxmpp/client.py index 606ffeb..44c192c 100644 --- a/nbxmpp/client.py +++ b/nbxmpp/client.py @@ -103,6 +103,7 @@ class Client(Observable): self._session_required = False self._connect_successful = False self._stream_close_initiated = False + self._ping_id = None self._error = None, None, None self._ignored_tls_errors = [] @@ -398,6 +399,7 @@ class Client(Observable): def _disconnect(self, immediate=True): self.state = StreamState.DISCONNECTING self._remove_ping_timer() + self._dispatcher.remove_ping_callback(self._ping_id) if not immediate: self._stream_close_initiated = True self._smacks.close_session() @@ -772,9 +774,12 @@ class Client(Observable): stanza.getErrorMsg()) def _ping(self): - iq = Iq('get', to=self._jid.getBare()) + self._ping_source_id = None + iq = Iq('get', to=self.domain) iq.addChild(name='ping', namespace=NS_PING) - self.send_stanza(iq, timeout=10, callback=self._on_pong) + self._ping_id = self.send_stanza(iq, + timeout=10, + callback=self._on_pong) self._log.info('Ping') def _on_pong(self, _client, result): |