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.

[Technical Question] Is there a way to generate connection status events as the state changes?

See original GitHub issue

I have a situation in which a set of actions must be run as soon as the state of the iot hub device connection changes and right now I don’t see a clean way to achieve this. I know I can poll the state of the connection using the connected property but what I’m really after is a way to turn this into an event based approach.

By looking at https://github.com/Azure/azure-iot-sdk-python/blob/master/azure-iot-device/azure/iot/device/iothub/aio/async_clients.py#L73-L74 I can see a way to hack my way around this limitation (by chaining handlers) but that would involve dealing with an object’s privates and because of this I don’t see it as a proper long term solution.

In the old SDK I was using IoTHubClient.set_connection_status_callback for this. Is there another way that I’m not seeing right now?

AB#7366705

Issue Analytics

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

github_iconTop GitHub Comments

3reactions
jebrandocommented, Aug 12, 2020

@zoopp Just an update on this. This work item has been been scheduled on our backlog and looks to be done sometime this fall

2reactions
cartertinneycommented, Jun 2, 2021

@zoopp This feature has now been added. There now exists a .on_connection_state_change handler that can be set on the client, which will be invoked every time the connection state changes. We recommend checking the connection state (the .connected attribute) in your handler definition as connection states can potentially change during the execution of the handler

This will be included as part of the next package release.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SqlConnection State Change in a strange way - Stack Overflow
1 Answer 1 · Be sure your connections use the same connection string each time. · Only open a connection when you need...
Read more >
Top 40 ReactJS Interview Questions and Answers for 2023
The change in state can happen as a response to user action or system-generated events. It determines the behavior of the component and...
Read more >
Analyze the wireless network report - Microsoft Support
Get step-by-step instructions on how to create and analyze the wireless network report in Windows 10, so you can fix Wi-Fi problems at...
Read more >
sudheerj/reactjs-interview-questions: List of top 500 ... - GitHub
How to listen to state changes? 103, What is the recommended approach of removing an array element in react state? 104, Is it...
Read more >
Visibility of System Status (Usability Heuristic #1)
A better way to build trust is to explicitly communicate the current system's status — which items are no longer available — and...
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