Fix xep-0199
The keepalive ping was not working, and and ping() was tracebacking due to a wrong parameter.
This commit is contained in:
parent
4905407092
commit
6b1a04f59d
@ -95,18 +95,20 @@ class XEP_0199(BasePlugin):
|
|||||||
self.timeout = timeout
|
self.timeout = timeout
|
||||||
|
|
||||||
self.keepalive = True
|
self.keepalive = True
|
||||||
|
handler = lambda event=None: asyncio.ensure_future(self._keepalive(event))
|
||||||
self.xmpp.schedule('Ping keepalive',
|
self.xmpp.schedule('Ping keepalive',
|
||||||
self.interval,
|
self.interval,
|
||||||
self._keepalive,
|
handler,
|
||||||
repeat=True)
|
repeat=True)
|
||||||
|
|
||||||
def disable_keepalive(self, event=None):
|
def disable_keepalive(self, event=None):
|
||||||
self.xmpp.cancel_schedule('Ping keepalive')
|
self.xmpp.cancel_schedule('Ping keepalive')
|
||||||
|
|
||||||
|
@asyncio.coroutine
|
||||||
def _keepalive(self, event=None):
|
def _keepalive(self, event=None):
|
||||||
log.debug("Keepalive ping...")
|
log.debug("Keepalive ping...")
|
||||||
try:
|
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:
|
except IqTimeout:
|
||||||
log.debug("Did not recieve ping back in time." + \
|
log.debug("Did not recieve ping back in time." + \
|
||||||
"Requesting Reconnect.")
|
"Requesting Reconnect.")
|
||||||
@ -172,8 +174,7 @@ class XEP_0199(BasePlugin):
|
|||||||
|
|
||||||
log.debug('Pinging %s' % jid)
|
log.debug('Pinging %s' % jid)
|
||||||
try:
|
try:
|
||||||
yield from self.send_ping(jid, ifrom=ifrom, timeout=timeout,
|
yield from self.send_ping(jid, ifrom=ifrom, timeout=timeout)
|
||||||
coroutine=True)
|
|
||||||
except IqError as e:
|
except IqError as e:
|
||||||
if own_host:
|
if own_host:
|
||||||
rtt = time.time() - start
|
rtt = time.time() - start
|
||||||
|
Loading…
x
Reference in New Issue
Block a user