Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[paho-dev] Help troubleshooting python paho.mqtt.client loop returns 1

Hello Paho-devs,

This is my first post on this list.

I'm trying to use the paho.mqtt client in a project on a raspberry pi.
I installed using pip:

pip install paho-mqtt

The problem I'm having is that intermittently, the paho.mqtt.client
"loop"-function returns 1.

Looking through the source, I see that this error code is defined as
MQTT_ERR_NOMEM. By sprinkling print statements in the source, I was
able to narrow it down to line 1420 in client.py:

                if len(command) == 0:
                    return 1

This is in the function _packet_read in the client class. This
executes, and the 1 is propagated all the way out to the return value
of the loop function.

The case when len(command)==0 seems like it should only occur if the
socket has been shutdown by the other end.

It seems to me to be a bug that 1 is returned here, since there's no
indication that memory would be out.

But the bigger question is why this happens in the first place. I'm
using the mosquitto server, and I've tried using mosquitto_sub to
subscribe to messages, and that seems to work "forever" without losing
connection, crashing or hanging or anything.

I'll continue my investigation, but I thought I'd ask on this list if
anyone has seen this before or has any clever approaches to finding
the cause of my problem.

The problem is repeatable, after starting my application it only runs
for approximately 1 minute, maybe 20-30 messages, before this happens.

Ofcourse I could just handle this error, reconnect, and continue, but
I'd like to get to the bottom of the issue :-).


/Anders


Back to the top