Context
- OS and version used: Windows 10
- Java runtime used: 17
- SDK version used: v1/v2
Description of the issue
I have met this issue with Azure IotHub SDK v1 about 1-2 months ago. It happened suddenly, I discovered this error in my automatic tests and there weren't any changes in libraries versions. Saying more, switching to SDK v2 gives the same errors. Despite this error with connection, DeviceTwin works, but DirectMethod has stopped working.
In summary: DirectMethod doesn't work anymore, independently of SDK versions
Code sample exhibiting the issue
Taking the examples of DirectMethod from official repo:
- https://github.com/Azure/azure-iot-sdk-java/blob/main/device/iot-device-samples
- https://github.com/Azure/azure-iot-sdk-java/blob/main/service/iot-service-samples
Console log of the issue
From service:
[main] DEBUG com.microsoft.azure.sdk.iot.service.methods.DirectMethodsClient - Initialized a DirectMethodsClient instance using SDK version 2.1.2
[main] DEBUG com.microsoft.azure.sdk.iot.service.jobs.ScheduledJobsClient - Initialized a ScheduledJobsClient instance using SDK version 2.1.2
[main] DEBUG com.microsoft.azure.sdk.iot.service.query.QueryClient - Initialized a QueryClient instance client using SDK version 2.1.2
directly invoke method on the Device
{"errorCode":404103,"message":"The operation failed because the requested device isn't online or hasn't registered the direct method callback. To learn more, see https://aka.ms/iothub404103","trackingId":"D2F86180CA32433CB850C20C034A4D87-G2:-TimeStamp:2022-09-24T15:35:29.240331067+00:00","timestampUtc":"2022-09-24T15:35:29.240331067+00:00","info":null}
Shutting down sample...
From device:
(onMethodInvoked in callback was reached but with empty payload)
22:40:12.655 [MQTT Rec: int-test-1] WARN com.microsoft.azure.sdk.iot.device.transport.mqtt.Mqtt - Mqtt connection lost
org.eclipse.paho.client.mqttv3.MqttException: Utracono połączenie
at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:197)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.io.EOFException: null
at java.base/java.io.DataInputStream.readByte(DataInputStream.java:273)
at org.eclipse.paho.client.mqttv3.internal.wire.MqttInputStream.readMqttWireMessage(MqttInputStream.java:92)
at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:137)
... 1 common frames omitted
22:40:12.655 [MQTT Rec: int-test-1] DEBUG com.microsoft.azure.sdk.iot.device.transport.IotHubTransport - Mapping throwable to NO_NETWORK because it was a retryable exception
com.microsoft.azure.sdk.iot.device.transport.ProtocolException: Mqtt connection lost
at com.microsoft.azure.sdk.iot.device.transport.mqtt.exceptions.PahoExceptionTranslator.convertToMqttException(PahoExceptionTranslator.java:63)
at com.microsoft.azure.sdk.iot.device.transport.mqtt.Mqtt.connectionLost(Mqtt.java:339)
at org.eclipse.paho.client.mqttv3.internal.CommsCallback.connectionLost(CommsCallback.java:304)
at org.eclipse.paho.client.mqttv3.internal.ClientComms.shutdownConnection(ClientComms.java:441)
at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:197)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: org.eclipse.paho.client.mqttv3.MqttException: Utracono połączenie
... 2 common frames omitted
Caused by: java.io.EOFException: null
at java.base/java.io.DataInputStream.readByte(DataInputStream.java:273)
at org.eclipse.paho.client.mqttv3.internal.wire.MqttInputStream.readMqttWireMessage(MqttInputStream.java:92)
at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:137)
... 1 common frames omitted
22:40:12.656 [MQTT Rec: int-test-1] WARN com.microsoft.azure.sdk.iot.device.transport.IotHubTransport - Updating transport status to new status DISCONNECTED_RETRYING with reason NO_NETWORK
com.microsoft.azure.sdk.iot.device.transport.ProtocolException: Mqtt connection lost
at com.microsoft.azure.sdk.iot.device.transport.mqtt.exceptions.PahoExceptionTranslator.convertToMqttException(PahoExceptionTranslator.java:63)
at com.microsoft.azure.sdk.iot.device.transport.mqtt.Mqtt.connectionLost(Mqtt.java:339)
at org.eclipse.paho.client.mqttv3.internal.CommsCallback.connectionLost(CommsCallback.java:304)
at org.eclipse.paho.client.mqttv3.internal.ClientComms.shutdownConnection(ClientComms.java:441)
at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:197)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: org.eclipse.paho.client.mqttv3.MqttException: Utracono połączenie
... 2 common frames omitted
Caused by: java.io.EOFException: null
at java.base/java.io.DataInputStream.readByte(DataInputStream.java:273)
at org.eclipse.paho.client.mqttv3.internal.wire.MqttInputStream.readMqttWireMessage(MqttInputStream.java:92)
at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:137)
... 1 common frames omitted
22:40:12.656 [MQTT Rec: int-test-1] DEBUG com.microsoft.azure.sdk.iot.device.transport.IotHubTransport - Invoking connection status callbacks with new status details
CONNECTION STATUS UPDATE: DISCONNECTED_RETRYING
CONNECTION STATUS REASON: NO_NETWORK
CONNECTION STATUS THROWABLE: Mqtt connection lost