Skip to content

[Bug Report] Unable to connect device client using MQTT_WS when there is high network latency #1648

@sesu-bio

Description

@sesu-bio

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions