Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug Report] Connection status reason for routine MQTT disconnects is incorrect #1405

Closed
timtay-microsoft opened this issue Nov 3, 2021 · 3 comments
Assignees
Labels
bug fix checked in Fix checked into main or preview, but not yet released. IoTSDK

Comments

@timtay-microsoft
Copy link
Member

Device/module clients that connect over MQTT are expected to lose connection once their SAS token has expired, but the connection status update that the SDK makes at this time is always "NO_NETWORK" instead of the expected "EXPIRED_SAS_TOKEN"

@timtay-microsoft
Copy link
Member Author

This is likely because the SDK classifies all retryable errors as NO_NETWORK before it even checks if the SAS token was expired:

@timtay-microsoft timtay-microsoft self-assigned this Nov 8, 2021
timtay-microsoft added a commit that referenced this issue Nov 8, 2021
…s didn't provide the correct reason (#1407)

The reason was always "NO_NETWORK"

#1405
@timtay-microsoft timtay-microsoft added the fix checked in Fix checked into main or preview, but not yet released. label Nov 8, 2021
@jamdavi
Copy link
Member

jamdavi commented Dec 20, 2021

We have added improvements in the latest release that should help with this issue and others. Please feel free to reopen if the upgraded library does not solve this problem.

https://github.com/Azure/azure-iot-sdk-java/releases/tag/2021-12-15

@jamdavi jamdavi closed this as completed Dec 20, 2021
@in-fke
Copy link

in-fke commented Sep 20, 2023

Device/module clients that connect over MQTT are expected to lose connection once their SAS token has expired

Just as a heads up, this used to be logged with WARN and Exceptions.
Apparently this was improved to only be logged with INFO and without stack, see
https://github.com/Azure/azure-iot-sdk-java/blob/main/iothub/device/iot-device-client/src/main/java/com/microsoft/azure/sdk/iot/device/transport/mqtt/Mqtt.java#L345
and
https://github.com/Azure/azure-iot-sdk-java/blob/main/iothub/device/iot-device-client/src/main/java/com/microsoft/azure/sdk/iot/device/transport/IotHubTransport.java#L1658

So I guess we will update and see how it goes with regard to log output.

2023-09-20T14:12:42,748 WARN  [MQTT Rec: soo-fnke] transport.mqtt.Mqtt:330 Mqtt connection lost
org.eclipse.paho.client.mqttv3.MqttException: Connection lost
	at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:197) [org.eclipse.paho.client.mqttv3-1.2.5.jar:?]
	at java.lang.Thread.run(Thread.java:829) [?:?]
Caused by: java.io.EOFException
	at java.io.DataInputStream.readByte(DataInputStream.java:272) ~[?:?]
	at org.eclipse.paho.client.mqttv3.internal.wire.MqttInputStream.readMqttWireMessage(MqttInputStream.java:92) ~[org.eclipse.paho.client.mqttv3-1.2.5.jar:?]
	at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:137) ~[org.eclipse.paho.client.mqttv3-1.2.5.jar:?]
	... 1 more
2023-09-20T14:12:42,751 WARN  [MQTT Rec: soo-fnke] device.transport.IotHubTransport:1629 Updating transport status to new status DISCONNECTED_RETRYING with reason EXPIRED_SAS_TOKEN
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) ~[iot-device-client-2.1.3.jar:?]
	at com.microsoft.azure.sdk.iot.device.transport.mqtt.Mqtt.connectionLost(Mqtt.java:339) [iot-device-client-2.1.3.jar:?]
	at org.eclipse.paho.client.mqttv3.internal.CommsCallback.connectionLost(CommsCallback.java:304) [org.eclipse.paho.client.mqttv3-1.2.5.jar:?]
	at org.eclipse.paho.client.mqttv3.internal.ClientComms.shutdownConnection(ClientComms.java:441) [org.eclipse.paho.client.mqttv3-1.2.5.jar:?]
	at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:197) [org.eclipse.paho.client.mqttv3-1.2.5.jar:?]
	at java.lang.Thread.run(Thread.java:829) [?:?]
Caused by: org.eclipse.paho.client.mqttv3.MqttException: Connection lost
	... 2 more
Caused by: java.io.EOFException
	at java.io.DataInputStream.readByte(DataInputStream.java:272) ~[?:?]
	at org.eclipse.paho.client.mqttv3.internal.wire.MqttInputStream.readMqttWireMessage(MqttInputStream.java:92) ~[org.eclipse.paho.client.mqttv3-1.2.5.jar:?]
	at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:137) ~[org.eclipse.paho.client.mqttv3-1.2.5.jar:?]
	... 1 more

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug fix checked in Fix checked into main or preview, but not yet released. IoTSDK
Projects
None yet
Development

No branches or pull requests

3 participants