From 6b1a04f59da7331230aaa9961b2ea0c81307745a Mon Sep 17 00:00:00 2001 From: mathieui Date: Sat, 28 May 2016 15:13:33 +0200 Subject: Fix xep-0199 The keepalive ping was not working, and and ping() was tracebacking due to a wrong parameter. --- slixmpp/plugins/xep_0199/ping.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/slixmpp/plugins/xep_0199/ping.py b/slixmpp/plugins/xep_0199/ping.py index bb2ceb38..8594ac01 100644 --- a/slixmpp/plugins/xep_0199/ping.py +++ b/slixmpp/plugins/xep_0199/ping.py @@ -95,18 +95,20 @@ class XEP_0199(BasePlugin): self.timeout = timeout self.keepalive = True + handler = lambda event=None: asyncio.ensure_future(self._keepalive(event)) self.xmpp.schedule('Ping keepalive', self.interval, - self._keepalive, + handler, repeat=True) def disable_keepalive(self, event=None): self.xmpp.cancel_schedule('Ping keepalive') + @asyncio.coroutine def _keepalive(self, event=None): log.debug("Keepalive ping...") try: - rtt = self.ping(self.xmpp.boundjid.host, timeout=self.timeout) + rtt = yield from self.ping(self.xmpp.boundjid.host, timeout=self.timeout) except IqTimeout: log.debug("Did not recieve ping back in time." + \ "Requesting Reconnect.") @@ -172,8 +174,7 @@ class XEP_0199(BasePlugin): log.debug('Pinging %s' % jid) try: - yield from self.send_ping(jid, ifrom=ifrom, timeout=timeout, - coroutine=True) + yield from self.send_ping(jid, ifrom=ifrom, timeout=timeout) except IqError as e: if own_host: rtt = time.time() - start -- cgit v1.2.3