comparison sat/plugins/plugin_xep_0198.py @ 2729:edd230651138

plugin XEP-0198: rised ACK_TIMEOUT + set req_time to None when timing out to be ready after resuming
author Goffi <goffi@goffi.org>
date Thu, 27 Dec 2018 09:21:10 +0100
parents 59ac9284dee8
children 25639611c303
comparison
equal deleted inserted replaced
2728:1b11da85492c 2729:edd230651138
58 # Max number of seconds before requesting ack 58 # Max number of seconds before requesting ack
59 MAX_DELAY_ACK_R = 30 59 MAX_DELAY_ACK_R = 30
60 MAX_COUNTER = 2**32 60 MAX_COUNTER = 2**32
61 RESUME_MAX = 5*60 61 RESUME_MAX = 5*60
62 # if we don't have an answer to ACK REQUEST after this delay, connection is aborted 62 # if we don't have an answer to ACK REQUEST after this delay, connection is aborted
63 ACK_TIMEOUT = 25 63 ACK_TIMEOUT = 35
64 64
65 65
66 class ProfileSessionData(object): 66 class ProfileSessionData(object):
67 out_counter = 0 67 out_counter = 0
68 in_counter = 0 68 in_counter = 0
135 log.error(_(u"Invalid ack_timeout value, please check your configuration")) 135 log.error(_(u"Invalid ack_timeout value, please check your configuration"))
136 self._ack_timeout = ACK_TIMEOUT 136 self._ack_timeout = ACK_TIMEOUT
137 if not self._ack_timeout: 137 if not self._ack_timeout:
138 log.info(_(u"Ack timeout disabled")) 138 log.info(_(u"Ack timeout disabled"))
139 else: 139 else:
140 log.info(_(u"Ack timeout set to {timeout} s").format( 140 log.info(_(u"Ack timeout set to {timeout}s").format(
141 timeout=self._ack_timeout)) 141 timeout=self._ack_timeout))
142 142
143 def profileConnecting(self, client): 143 def profileConnecting(self, client):
144 client._xep_0198_session = ProfileSessionData(callback=self.checkAcks, 144 client._xep_0198_session = ProfileSessionData(callback=self.checkAcks,
145 client=client) 145 client=client)
450 450
451 def onAckTimeOut(self, client): 451 def onAckTimeOut(self, client):
452 """Called when a requested ACK has not been received in time""" 452 """Called when a requested ACK has not been received in time"""
453 log.info(_(u"Ack was not received in time, aborting connection")) 453 log.info(_(u"Ack was not received in time, aborting connection"))
454 client.xmlstream.transport.abortConnection() 454 client.xmlstream.transport.abortConnection()
455 client._xep_0198_session.req_time = None
455 456
456 457
457 class XEP_0198_handler(xmlstream.XMPPHandler): 458 class XEP_0198_handler(xmlstream.XMPPHandler):
458 implements(iwokkel.IDisco) 459 implements(iwokkel.IDisco)
459 460