Closed AlanPintor-git closed 1 year ago
Can you share the stacktrace that you see when sending telemetry fails?
Hi @timtay-microsoft, thanks for the following.
The Error is coming from IotHubEventCallback:
private static class EventCallback implements IotHubEventCallback {
@Override
public void execute(IotHubStatusCode responseStatus, Object callbackContext) {
StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
StringBuilder stackTraceString = new StringBuilder();
for (StackTraceElement element : stackTraceElements) {
stackTraceString.append(element.toString()).append("\n");
}
Log.v("IoTest", "IotHubEventCallback >> Telemetry sent with status: " + responseStatus.name());
Log.v("IoTest", "Current stack trace:\n" + stackTraceString);
}
}
Error:
Do you see any errors when using other protocols? Such as:
deviceClient = new DeviceClient(connectionString, IotHubClientProtocol.AMQPS);
or
deviceClient = new DeviceClient(connectionString, IotHubClientProtocol.MQTT);
Hi @timtay-microsoft, thanks for the follow-up.
Yes, the error is the same for all protocols except HTTPS. The error sample below is from the MQTT protocol:
V/IoTest: Error connecting to Azure IoT Central: Could not open the connection W/System.err: java.io.IOException: Could not open the connection at com.microsoft.azure.sdk.iot.device.DeviceIO.open(DeviceIO.java:162) at com.microsoft.azure.sdk.iot.device.InternalClient.open(InternalClient.java:176) at com.microsoft.azure.sdk.iot.device.DeviceClient.open(DeviceClient.java:438) at com.osak.csjrobotmanager.Services.AzureIoTHelper.iotConnect(AzureIoTHelper.java:40) W/System.err: at com.osak.csjrobotmanager.Activity.MainActivity.onCreate(MainActivity.java:171) at android.app.Activity.performCreate(Activity.java:6709) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2624) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2732) at android.app.ActivityThread.-wrap12(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1483) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6141) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:913) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:803) W/System.err: Caused by: com.microsoft.azure.sdk.iot.device.exceptions.ProtocolException: Unable to establish MQTT connection at com.microsoft.azure.sdk.iot.device.transport.mqtt.exceptions.PahoExceptionTranslator.convertToMqttException(PahoExceptionTranslator.java:46) at com.microsoft.azure.sdk.iot.device.transport.mqtt.Mqtt.connect(Mqtt.java:136) at com.microsoft.azure.sdk.iot.device.transport.mqtt.MqttMessaging.start(MqttMessaging.java:63) at com.microsoft.azure.sdk.iot.device.transport.mqtt.MqttIotHubConnection.open(MqttIotHubConnection.java:277) at com.microsoft.azure.sdk.iot.device.transport.IotHubTransport.openConnection(IotHubTransport.java:999) at com.microsoft.azure.sdk.iot.device.transport.IotHubTransport.open(IotHubTransport.java:392) at com.microsoft.azure.sdk.iot.device.DeviceIO.open(DeviceIO.java:158) ... 16 more W/System.err: Caused by: MqttException (0) - javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found. W/System.err: at org.eclipse.paho.client.mqttv3.internal.ExceptionHelper.createMqttException(ExceptionHelper.java:38) at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:736) at java.lang.Thread.run(Thread.java:761) Caused by: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found. at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:361) at org.eclipse.paho.client.mqttv3.internal.SSLNetworkModule.start(SSLNetworkModule.java:149) at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:722) ... 1 more Caused by: java.security.cert.CertificateException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found. at com.android.org.conscrypt.TrustManagerImpl.checkTrustedRecursive(TrustManagerImpl.java:549) W/System.err: at com.android.org.conscrypt.TrustManagerImpl.checkTrustedRecursive(TrustManagerImpl.java:508) at com.android.org.conscrypt.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:401) at com.android.org.conscrypt.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:375) at com.android.org.conscrypt.TrustManagerImpl.getTrustedChainForServer(TrustManagerImpl.java:304) at android.security.net.config.NetworkSecurityTrustManager.checkServerTrusted(NetworkSecurityTrustManager.java:94) at android.security.net.config.RootTrustManager.checkServerTrusted(RootTrustManager.java:88) at com.android.org.conscrypt.Platform.checkServerTrusted(Platform.java:178) at com.android.org.conscrypt.OpenSSLSocketImpl.verifyCertificateChain(OpenSSLSocketImpl.java:596) at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method) at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:357) ... 3 more Caused by: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found. ... 14 more V/IoTest: sendTelemetries - Exception: Cannot send event from an IoT Hub client that is closed., cause: null, stackTraceString: java.lang.IllegalStateException: Cannot send event from an IoT Hub client that is closed. at com.microsoft.azure.sdk.iot.device.DeviceIO.sendEventAsync(DeviceIO.java:322) at com.microsoft.azure.sdk.iot.device.InternalClient.sendEventAsync(InternalClient.java:216) at com.osak.csjrobotmanager.Services.AzureIoTHelper.sendTelemetries(AzureIoTHelper.java:62) at com.osak.csjrobotmanager.Activity.MainActivity.onCreate(MainActivity.java:177) at android.app.Activity.performCreate(Activity.java:6709) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2624) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2732) at android.app.ActivityThread.-wrap12(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1483) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6141) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:913) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:803) W/System.err: java.lang.IllegalStateException: Cannot send event from an IoT Hub client that is closed. at com.microsoft.azure.sdk.iot.device.DeviceIO.sendEventAsync(DeviceIO.java:322) W/System.err: at com.microsoft.azure.sdk.iot.device.InternalClient.sendEventAsync(InternalClient.java:216) at com.osak.csjrobotmanager.Services.AzureIoTHelper.sendTelemetries(AzureIoTHelper.java:62) at com.osak.csjrobotmanager.Activity.MainActivity.onCreate(MainActivity.java:177) at android.app.Activity.performCreate(Activity.java:6709) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2624) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2732) at android.app.ActivityThread.-wrap12(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1483) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6141) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:913) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:803)
Have you tried upgrading the SDK version to either the latest v1 release (1.34.3) or to the latest v2 release (2.2.0)?
Yes, I am experiencing issues with Android compatibility. However, I will attempt again using the specific version(s) you recommended. I will keep you updated. Thank you.
Hello @timtay-microsoft,
I keep encountering the same Android compatibility issues. Initially, the IDE prompted me to upgrade, but after resolving many issues, it's now suggesting that I downgrade. I feel like I'm going in circles. Can you provide a compatible sample for my project or recommend effective solutions? Thanks in advance,
Closing as stale
Dear Azure Team,
I am reaching out to reopen a previously raised issue regarding the Azure SDK upgrade for our Android application. Despite earlier efforts, we continue to face challenges in this process.
Our main difficulty lies in the absence of detailed documentation. The available "Quickstart" guide only offers an APK, which unfortunately does not meet our needs as it lacks the source code.
To facilitate a smoother upgrade process, could you kindly provide us with the Android source code or a simple demonstration? Specifically, we are looking for a way to send telemetry data to Azure IoT Central from an Android device.
Your assistance in providing these resources would be highly valuable in helping us resolve the issues we are encountering.
Thank you for your attention and support.
Dear IoT Team,
I am encountering challenges while attempting to integrate a robot with IoT Central. This is a critical issue as it pertains to one of many units that require connection.
Project Configuration Details:
implementation 'com.microsoft.azure.sdk.iot:iot-device-client:1.29.2'
The challenges faced are as follows:
//V/IoTest: Telemetry sent with status: ERROR
Would you be able to provide a sample compatible with my project configuration, or advise me on appropriate solutions?
Enclosed code snippet:
Best Regards, Alan