question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Reconnecting smoothly

See original GitHub issue

https://github.com/aws/aws-iot-device-sdk-python/blob/47363e9b9bc0a4ecd5896d0f90cc685498e9b3ea/AWSIoTPythonSDK/core/protocol/mqtt_core.py#L248

Hello,

First thanks for creating/maintaining this sdk. From the documentation, it states that you provide:

It provides basic synchronous MQTT operations in the classic MQTT publish-subscribe model, along with configurations of on-top features: - Auto reconnect/resubscribe - Progressive reconnect backoff - Offline publish requests queueing with draining

However, I’m not experiencing these features. I expect when I call awsMQTTClient.publish(topic, message, qos) I expect not to ever get a publishTimeoutException(), except maybe when the maxReconnectQuietTimeSecond in configureAutoReconnectBackoffTime (docs) is exceeded. However, I get publishTimeoutException() quite often.

Do I have to do something like this now everytime I publish?

        try:
            myMQTTClient.publish("testing/IoT", message, 1)
        except:
            print(err)
            myMQTTClient.connect()
            myMQTTClient.publish("testing/IoT", message, 1)

What’s the proper way of recovering from this type of timeout?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
graebmcommented, Dec 4, 2019

Publishes do not affect the client’s attempts to reconnect. Reconnects occur when the underlying socket reports that the connection is lost, or when the MQTT Client doesn’t get a response to the PING packets it is sending to the server at regular intervals (“keep alive” values affect the rate that these PING packets are sent)

1reaction
GlennScommented, Oct 11, 2018

Just noting that I had a similar issue when running inside uwsgi (using Flask), in case anyone else comes across this and needs help.

I fixed it by making sure to construct and connect my AWSIoTMQTTClient instance in the same context (probably a thread?) that requests run in. I still reuse the instance between different requests though, because calling connect() on the client takes some time.

Read more comments on GitHub >

github_iconTop Results From Across the Web

4 Ways to Reconnect to Your Habits and Reset Your ...
4 ways to reconnect to your habits and reset your boundaries when they slip (because they will!) Sometimes it feels like I should...
Read more >
How to Reconnect With An Old Friend Without Making It ...
This article discusses the benefits of reconnecting with old friends, reasons why it may be awkward, and some tips that can help you...
Read more >
Remember Me? The Art Of Reconnecting - Margot Andersen
Learning how to genuinely re-engage with our past connections can prove not only to be a key determinant of our future success and...
Read more >
Rebuilding the Pyramid: Reconnecting After a Break
After a long break, it's likely children and adults may forget some of the routines that make the school day go smoothly. To...
Read more >
Smooth/silent/fully-automatic RDP reconnect on server reboot
I have tested a lot of RDP connection managers recently and RDM seems the best one. The only feature I am missing from...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found