Skip to content

unexpected MQTT_ERR_KEEPALIVE when chunk cannot be received within keepalive interval #914

Description

@Uezzi

When trying to request one large message (~100 MB) from mqtt broker, connection is reset with MQTT_ERR_KEEPALIVE error when chunk cannot be received within double of configured keepalive interval.

Using following pseudo code:

import paho.mqtt.client as mqtt
client = mqtt.Client()
client.connect(my_url, keepalive=30)

When chunk is not received within 60 seconds, MQTT_ERR_KEEPALIVE will occur.

Reason: Keep-Alive timeout detection is done by _check_keepalive() function using self._last_msg_out and self._last_msg_in.
self._last_msg_in is properly updated after a full packed has been received and after reading 100 parts of a huge packet. However there might happen a BlockingIOError when calling self._sock_recv(). This happens with my setup regularly. In this case self._last_msg_in is not updated, resulting in keepalive error.

Suggested fix: update self._last_msg_in regularly whenever data is received from socket.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: AvailableNo one has claimed responsibility for resolving this issue.

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions