gmqtt icon indicating copy to clipboard operation
gmqtt copied to clipboard

[PROPERTIES] received invalid property id 105, disconnecting

Open hollymcr opened this issue 3 years ago • 2 comments

I don't understand the code well enough to make sense of what I am seeing here, but I am sometimes getting exceptions thrown in MqttPackageHandler._handle_publish_packet() due to the returned value of properties from qttPackageHandler._parse_parameters() being None:

[PROPERTIES] received invalid property id 105, disconnecting
[ERROR HANDLE PKG]
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/gmqtt/mqtt/handler.py", line 389, in __call__
    result = self._handle_packet(cmd, packet)
  File "/usr/local/lib/python3.7/dist-packages/gmqtt/mqtt/handler.py", line 214, in _handle_packet
    handler(cmd, packet)
  File "/usr/local/lib/python3.7/dist-packages/gmqtt/mqtt/handler.py", line 326, in _handle_publish_packet
    properties['dup'] = dup
TypeError: 'NoneType' object does not support item assignment
2

Looking at the code in _handle_connack_packet, a test is made for None and a call to self.disconnect() queued. But _handle_publish_packet() makes no such test, before assuming that properties is a Dict that can be assigned to.

Should there be a test here leading to a disconnect (as elsewhere)? That the error message from _parse_parameters says "disconnecting" but then doesn't attempt to (depending on where it is called from) suggests this is a suitable fix but I don't know what the implications might be.

hollymcr avatar Mar 30 '21 17:03 hollymcr

Hi @hollymcr

Thanks for your issue, may you provider which mqtt-broker do you use?

Mixser avatar Apr 02 '21 11:04 Mixser

Mosquitto (standard install via apt on Ubuntu Server 20.04) over SSL.

On Fri, 2 Apr 2021 at 12:05, Mike Turchunovich @.***> wrote:

Hi @hollymcr https://github.com/hollymcr

Thanks for your issue, may you provider which mqtt-broker do you use?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/wialon/gmqtt/issues/125#issuecomment-812483662, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACLDI24GLJ7OUYJSPXZ73M3TGWQFXANCNFSM42CSRXHA .

-- Mark Rogers // More Solutions Ltd (Peterborough Office) // 0844 251 1450 Registered in England (0456 0902) 21 Drakes Mews, Milton Keynes, MK8 0ER

hollymcr avatar Apr 02 '21 11:04 hollymcr