Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

out of memory crash + disconnection in exit of context manager when using qos=2 (paho 1.3.1) #250

Closed
axd1967 opened this issue Nov 25, 2017 · 9 comments

Comments

@axd1967
Copy link

axd1967 commented Nov 25, 2017

for some dark reason, an out of memory error + disconnection occurs when publishing a qos=2 message.

I've created a small Vagrant VM that runs a RabbitMQ config and a client that attempts to send such a message: https://github.com/axd1967/paho-bug

the bug seems to happen upon exit of a context manager in publish() in paho/mqtt/client.py(1121):

return message.info

(note: code simplified, I can successfully send qos=0 and qos=1 messages via RabbitMQ)

paho-mqtt (1.3.1) , Ubuntu 16

@axd1967
Copy link
Author

axd1967 commented Nov 27, 2017

@axd1967
Copy link
Author

axd1967 commented Dec 1, 2017

Aha! qos=2 is a no-go for MQTT for specific reasons:

I think that closes part of the issue (but the crash should not happen)

in fact, the MQTT plugin could maybe issue big fat warnings on any QoS=2 use encountered, rather than let users find out? (but it is indeed documented on the top of the MQTT plugin doc page).

@PierreF
Copy link
Contributor

PierreF commented Dec 4, 2017

Thank for your patience and report detailed report.

RabbitMQ don't like QoS=2 package, but on my quick test (docker run rabbitmq, then rabbitmq-plugins enable rabbitmq_mqtt) I don't reproduce an out of memory. The client only get disconnected as soon as it publish the message and reconnect (in loop). Which is expected if the broker don't support them :)

I will try to test you Vagrant file in the next days.

@axd1967
Copy link
Author

axd1967 commented Dec 4, 2017

indeed, that seems to be what is happening (disconnect + reconnect, but including an out-of-memory error)
(edit added: Ubuntu 16)

@PierreF
Copy link
Contributor

PierreF commented Dec 6, 2017

Are you saying you have out of memory because the disconnect error is "Out of memory." ?
There is no out-of-memory in this cause, just a wrong number for this error :)

This come from

which use "1" instead of an MQTT_ERR_XXX.

So except for a wrong error message, there is no other issue.

@axd1967
Copy link
Author

axd1967 commented Dec 15, 2017

did you try the Vagrant approach?

I crafted it specially, the README explains the steps to reproduce the issue.

why does a disconnection happens? it looks like qos=2 is not correctly dealt with.

@PierreF
Copy link
Contributor

PierreF commented Dec 15, 2017

What I reproduce is RabbitMQ closing the connection (because it don't support QoS=2). On the client side I don't see any bad behavior (except the message / return code which is not the good one).

That why I asked if the "Out of memory" come only from the error_string(result). If that the case, the only issue on paho side is that a return 1 is used for a generic error, but MQTT_ERR_NOMEM also have the value 1. Paho should be updated to return a most useful error.

Paho can't do anything better with QoS=2 and RabbitMQ, the broker don't support it and you should either use only QoS < 2 or use another broker.

@YoungPyDawan
Copy link

At least issue from
#250 (comment)
is fixed in 1.6 branch:
https://github.com/eclipse/paho.mqtt.python/blame/1.6.x/src/paho/mqtt/client.py#L2373

by commit 332834e
so close?

@ralight
Copy link
Contributor

ralight commented Oct 4, 2021

I think so, yes, thanks for flagging this.

@ralight ralight closed this as completed Oct 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants