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.

Recommendation on handling publishTimeoutException

See original GitHub issue

Visiting this issue I was hoping to find some guidance on how to handle a publishTimeoutException, perhaps a generalized exception wrapper like:

mqtt_publish(mqttClient, topic, msg, attempt_count = 0, attempt_threshold = 3):
    '''Use mqtt to publish a message, if the connection fails then retry attempt_threshold times'''
    if attempt_count < attempt_threshold: 
        try:
            mqttClient.publish(topic, msg, 1)
        except AWSIoTPythonSDK.exception.AWSIoTExceptions.publishTimeoutException as e:
            attempt_count+=1
            mqtt_publish(mqttClient, topic, msg, attempt_count)
    else:
         mqttClient.publish(topic, msg, 1)

I didn’t find a recommendation to that effect, plus it seems as though publishTimeoutException could have broader meaning than just, “Server connection timed out” for example by too large of a message (> 128 KB).

Would the above pseudocode be an acceptable way to generalize the exception handling, or is there more to the publishTimeoutException that ought be accounted for?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

6reactions
cnrmckcommented, Feb 25, 2020

Yes, still interested.

I have not implemented any particular code to handle the issue.

It seems that perhaps this function coupled with the offline queue could cause duplicate message delivery (without setting the dup flag) so I have not implemented this in case I want to filter duplicate messages on my broker side.

Really the question is still open considering handling the publishTimeoutException is such a broad error.

0reactions
github-actions[bot]commented, Jan 26, 2022

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Publish and Subscribe Time out in my code while sample ...
Hi, Im created my own AWS client class that i am using in one of my python project. The sample project connect_device_package is...
Read more >
AWSIoTPythonSDK publishTimeoutException - Stack Overflow
I want to publish back once i get a get a data from Subscribe topic. However when i do so, AWSIoTPythonSDK throws exception...
Read more >
Omega2 aws connect error, SSL certificate verify failed
Hi everyone, I am working on project where i need to connect Omega2 to AWS Iot core. I had followed AWS Omega2 tutorial...
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