Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[paho-dev] Found the problem

> Hi again all,
>
> I found the problem.
>
> I had been calling loop with a timeout value of 1000 (since I
> accidentally used ms instead of s), but the timeout for the connection
> was less than that. I was kind of expecting that the loop-call would
> be sending the required keepalives anyway. But it doesn't do that,
> hence the server didn't get a keepalive in time and thus the
> connection got torn down from the server end.
>
> So I propose the following changes:
>
> The line:
>
> if len(command) == 0:
>                     return 1
>
> should be changed into:
>
> if len(command) == 0:
>                     return MQTT_ERR_CONN_LOST
>
> and possibly something like this added to the beginning of the loop-method:
>
> if timeout >= self._keepalive:
>             raise ValueError('Invalid timeout. Timeout must not be
> greater or equal to keepalive interval. It should be significantly
> smaller.')
>
> Also, I found that the following line:
> if (self._sock is not None or self._ssl is not None) and (now -
> last_msg_out >= self._keepalive or now - last_msg_in >=
> self._keepalive):
>
> causes problem. The keepalive should be sent more often than the
> timeout interval, right? So maybe divide self._keepalive by 2 in this
> use?
>
> Thank you for your product, and have a nice day all of  you! :-)
>
> /Anders


Back to the top