eclipse / paho.mqtt.python

paho.mqtt.python
Other
2.15k stars 724 forks source link

Subscribe fails if there is a large block of persistent packet in outboundMsg #721

Closed cuttlfish closed 1 week ago

cuttlfish commented 1 year ago

In MQTT sync mode, I am seeing a failure in subscribe if cleanSession is set to 0 and there is a large (> 1 MB) data in persistent data that needs to be stored.

First a large persisent data gets restored with this print

 Partial write: 43440 bytes of 11184910 actually written on socket 59

The subscribe fails with this message

 Trying to write to socket 59 for which there is already pending output

I am calling subscribe right after MQTT connects which succeeded. But it seems that the socket layer still have not finish writing the persistent packet in outboundMsgs. The failure in subscribe causes MQTT to disconnect due to SOCKET_ERROR returned.

It seems the subscribe should be done before any persistent packets gets restored?

MattBrittan commented 6 months ago

Apologies for the delay in responding.

Is there any chance you could provide a minimal version of your code (it's easy to send the larger message with mosquitto_pub for testing but a lot quicker for us to duplicate this if we have your code).

MattBrittan commented 1 week ago

I'm going to close this due to it's age/inactivity. Please do feel free to reopen if you are able to provide code to reproduce the issue.