Martti Käärik Greetings!
C2D and device telemetry messages go through normally, but 5 minutes after connecting to IoT Hub, the connection is closed and Amqp trace prints "error:.amqp:unauthorized-access".
The error message "error:.amqp:unauthorized-access" indicates that the connection is being closed due to an authentication issue.
One possible reason for this issue is that the SAS token used for authentication is expiring after 5 minutes.
SAS tokens have a default lifetime of 1 hour, but this can be customized. If the SAS token is expiring after 5 minutes, then the connection will be closed and the device will need to reconnect with a new SAS token.
To resolve this issue, you can try increasing the lifetime of the SAS token used for authentication**.**
I would suggest you, please check Understand and resolve Azure IoT Hub errors for more details and troubleshooting guide for common problems.
Do let me know if you have any further queries.