wialon / gmqtt

Python MQTT v5.0 async client
MIT License
385 stars 53 forks source link

fixed server_keep_alive #144

Closed mlaass closed 1 year ago

mlaass commented 1 year ago

When a server such as mochi MQTT sends a server_keep_alive property on CONNACK the handler would fail at "connection.py", line 108, in keepalive, trying to divide a list. example output:

ERROR:gmqtt.mqtt.handler:[ERROR HANDLE PKG]
Traceback (most recent call last):
  File "/home/*********/handler.py", line 383, in __call__
    result = self._handle_packet(cmd, packet)
  File "/home/*********/handler.py", line 214, in _handle_packet
    handler(cmd, packet)
  File "/home/*********/handler.py", line 289, in _handle_connack_packet
    self._update_keepalive_if_needed()
  File "/home/*********/handler.py", line 257, in _update_keepalive_if_needed
    self._connection.keepalive = self._keepalive
  File "/home/*********/connection.py", line 108, in keepalive
    self._keep_connection_callback = asyncio.get_event_loop().call_later(self._keepalive / 2, self._keep_connection)
TypeError: unsupported operand type(s) for /: 'list' and 'int'
sivaNbalusu5 commented 1 year ago

@Lenka42 @mlaass Can we have a new version with this fix, I am currently facing this issue.

Lenka42 commented 1 year ago

@mlaass thanks for PR! @sivaNbalusu5 very sorry about the delay. Guys, please check version 0.6.12, must be in Pypi already