Azure / Azure/azure-iot-sdk-java
[Bug Report] Unable to connect device client using MQTT_WS when there is high network latency
- Dominant language
- Java
- Stars
- 210
- Forks
- 238
- Avg merge
- 4d 9h
- Merged PRs (30d)
- 7
Description
# Context
- **OS and version used:** BuildRoot Linux 2022.02.7
- **Java runtime used:** openjdk version "1.8.0_352"
- **SDK version used:** iot-device-client 1.31.0, can reproduce with 2.1.3
## Description of the issue
Hi, Several of our devices in Australia are unable to connect to Azure via 3G. We think that the problems are related to a higher network latency there. When we simulate a high latency here, the logs look the same as the ones from Australia. To do that, we use the following command on Linux:
`tc qdisc add dev usb0 root netem delay 200ms`
Note that the higher latency only causes problems when using the MQTT_WS protocol. When using MQTT, the connection can be established without problems in our test setup.
## Code sample exhibiting the issue
We can reproduce the issue with the following code. It uses iot-device-client 2.1.3. The command above needs to be executed first to reproduce the issue.
```
SSLContext sslContext = new AzureSslContextFromCredentials().apply(PUB_KEY_CERT, PRIV_KEY, null);
ClientOptions clientOptions = ClientOptions.builder().sslContext(sslContext).build();
DeviceClient client = new DeviceClient(CONNECTION_STRING, PROTOCOL, clientOptions);
try {
client.open(false);
System.out.println("Connected successfully!");
} catch (IotHubClientException e) {
System.out.println("Error connecting!");
e.printStackTrace();
}
System.out.println("finished");
```
## Console log of the issue
[error_log.txt](https://github.com/Azure/azure-iot-sdk-java/files/10246439/error_log.txt)
Contributor guide
Assessment
This issue has not been assessed yet.