I am using IoT hub for my mobile application. I want to known the connect/disconnect status of my device. So I used Event Grid disconnect event. But I didn't get any status using mobile device. But when try https://azure-samples.github.io/raspberry-pi-web-simulator/#Getstarted , the status will return. But using mobile app and send same data, it's not working properly.
2 Answers
Actually the documentation recommends, as a good practice, to implement the heartbeat pattern for these kind of situations.
The idea is to send D2C messages every once in a while, and then to detect the devices which messsage did not arrived longer than a certain time-treshold.
For example, one simple way is that you can store the HB messages to the CosmosDB so that each HB message overrides the previous one(using device id as document id), and have time triggered function that would check which devices have reported the hb message older than X-time.

- 2,441
- 1
- 9
- 21
Could you please share which protocol are you using to connect to Azure IoT Hub using mobile application.The example for Raspberry uses MQTT and eventgrid works well with MQTT but you need to do a small change to make AMQP work with EventGrid.

- 120
- 1
- 7