An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
Hello Helix Sense,
These could be some of the few reasons behind delaying/buffering and recommended actions to fix it.
Possible Reasons:
- Network or Port Conflicts: If your devices are running IoT Edge, port conflicts (especially on 443, 5671, or 8883) can prevent modules like edgeHub from starting properly. This can cause delays in message routing.
- Telemetry Queue Timeout: The Azure IoT Device Client SDK (including Node.js) have a telemetry queue with a configurable timeout. By default, this timeout is set to 4 minutes. If a telemetry message is not sent within this timeout, it will trigger a callback with the result
IOTHUB_CLIENT_CONFIRMATION_MESSAGE_TIMEOUT. You can adjust this timeout setting to better suit your needs. Reference on Telemetry Que timeout - Message Size , Quota and Throttling: Ensure that the total message size, including any enrichments, does not exceed 256 KB. If a message exceeds this size, the IoT Hub will throw an exception. Additionally, check if you have exceeded the allocated quota for messages on the IoT Hub. Reference Quota and Throttling
- Buffering and Batching: The Azure IoT SDKs provide solutions for bandwidth savings, such as buffering and batching. Buffering allows the device to store data when connectivity is poor, and batching reduces the number of messages transmitted by merging information from multiple messages into a single batch. Ensure that these settings are configured correctly for your scenario Reference on Buffering
- Node.js SDK or PM2 Process Issues: Restarting the process with PM2 resolves the issue, which suggests a memory leak, unhandled exception, or socket exhaustion in your Node.js app. Consider enabling verbose logging and monitoring memory usage over time.
Solution:
- Inspect IoT Hub Metrics: Look at metrics like message count, latency, and dropped messages in Azure Monitor. If there is no drop in throughput, check your routing rules and ensure they are working as expected. Please check if you are facing any throttling error from activities or metrics tab and upgrade your IOT Hub if needed.
- Enable Debug Logging**:** Enable debug logs for IoT Hub and your devices to pinpoint where delays occur. Reference on logging library
- Test a Direct Send: Try sending a test message and monitor whether it gets delayed.
- Optimize Message Routing: Modify IoT Hub message routing to avoid unnecessary buffering if batching is enabled. Enable fall back routing endpoints.
- Modify the data retention period in Azure portal to clear out very old data post retention period. In the "Data Retention" blade, you can set the retention time for your data. You can choose to keep the data for a specific number of days (e.g. 7 days) or to delete it immediately. Once you have set the retention time, click on "Save" to apply the changes. Reference thread on Data retention
- Ensure Network Stability: If latency is suspected, check network performance.
- Diagnostic Logs: Use Azure Monitor Logs to troubleshoot connectivity issues. Create a diagnostic setting to send IoT Hub Connections logs to a Log Analytics workspace. This can help you identify common issues and understand the reasons behind device disconnects. Reference document on monitoring IOT hub
- Update SDK and Dependencies: Ensure that you are using the latest version of the Node.js SDK and PM2 are up to date. Sometimes, issues can arise from outdated software Reference on SDKs
- Consider Scaling: If you're on a Standard tier, you may need to scale up or distribute load across multiple hubs.
Hope this helps.
Thank you!