A category of Azure services for internet of things devices.
Hello John,
This behavior is expected when you're using SAS token authentication. A SAS token contains an expiration (se) timestamp, and once it expires the Azure IoT Hub client must authenticate again. The Azure IoT SDKs generally don't support replacing the SAS token on an existing MQTT/AMQP connection. Instead, the recommended approach is to:
Generate a new SAS token before the current one expires.
Disconnect the IoT Hub client.
Recreate the client using the new SAS token.
Reconnect and resume sending telemetry.
If your application requires seamless long-running connectivity, consider using Microsoft Entra ID (Azure AD) authentication (where supported) or X.509 certificates instead of manually managed SAS tokens. These methods eliminate the need for periodic SAS token regeneration.
If you're using the STM NetX Duo sample (nx_azure_iot_hub_client_connect()), you'll likely need to update the authentication callback or recreate the NX_AZURE_IOT_HUB_CLIENT instance with the new token, as there isn't an API to swap the SAS token on an active connection.
Please "Accept the Answer" if this information helped you. This will help us and others in the community as well.