there is a library for Azure IoT error code troubleshooting https://learn.microsoft.com/en-us/azure/iot-hub/troubleshoot-error-codes you can review this document in addition to this Azure IoT device SDKs disconnect and then reconnect when they renew SAS tokens over the MQTT protocol. This can appear as periodic disconnects in logs. https://learn.microsoft.com/en-us/azure/iot-hub/iot-hub-troubleshoot-connectivity For the error code in Java Make sure that you're using the correct method for encoding and decoding Base64. Java provides java.util.Base64 for these operations. For decoding, use Base64.getDecoder().decode(string). You can use online Base64 validation tools to check if your Base64 string is valid.
Iot Hub - Connection failed suddenly beacuse of bad credential
Winnie Cheng
0
Reputation points
We have multiple IoT devices created with self-defined key around 1-2 years ago and keep connecting to IoT Hub till 23/01/2024. All of a sudden, some of the devices disconnected due to bad credential. We have finished the certificate migration in last yeat Oct. So we don't think this should be the certificate issue. Also, we try to copy the crediential from azure poretal and test with Azure IoT device java SDK,
DeviceClient iotHubClient = new DeviceClient(DEVICE_CONNECTION_STR, protocol);
the following error was shown.
java.lang.IllegalArgumentException: Last encoded character (before the paddings if any) is a valid base 64 alphabet but not a possible value. Expected the discarded bits to be zero.
@org.apache.commons.codec.binary.Base64.validateCharacter(Base64.java:803)
org.apache.commons.codec.binary.Base64.decode(Base64.java:482)
org.apache.commons.codec.binary.BaseNCodec.decode(BaseNCodec.java:481)
org.apache.commons.codec.binary.Base64.decodeBase64(Base64.java:713)
com.microsoft.azure.sdk.iot.device.auth.SignatureHelper.decodeDeviceKeyBase64(SignatureHelper.java:56)
com.microsoft.azure.sdk.iot.device.auth.Signature.<init>(Signature.java:24)
com.microsoft.azure.sdk.iot.device.auth.IotHubSasToken.<init>(IotHubSasToken.java:81)
com.microsoft.azure.sdk.iot.device.auth.IotHubSasTokenSoftwareAuthenticationProvider.<init>(IotHubSasTokenSoftwareAuthenticationProvider.java:46)
com.microsoft.azure.sdk.iot.device.ClientConfiguration.configSasAuth(ClientConfiguration.java:160)
com.microsoft.azure.sdk.iot.device.ClientConfiguration.<init>(ClientConfiguration.java:202)
com.microsoft.azure.sdk.iot.device.InternalClient.<init>(InternalClient.java:48)
com.microsoft.azure.sdk.iot.device.DeviceClient.<init>(DeviceClient.java:81)
com.microsoft.azure.sdk.iot.device.DeviceClient.<init>(DeviceClient.java:60)
```Any help would be appreciated. Thanks
Azure IoT Hub
Azure IoT Hub
An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
1,272 questions