Closed FlorisDevreese closed 5 years ago
Thank you for opening this issue. I am looking into this.
I tried the above sample with slight modifications on Linux (ubuntu 18.04) and was unable to reproduce the issue. The steps I followed are:
int connectionStatusChangeCount = 0;
s_deviceClient.SetConnectionStatusChangesHandler((status, statusChangeReason) =>
{
connectionStatusChangeCount++;
Console.WriteLine($"{nameof(ConnectionStatusChangesHandler)}: status={status} statusChangeReason={statusChangeReason} count={connectionStatusChangeCount}");
});
tcpkill -i eth0 host <IP_of_my_IoTHub>
tcpkill
command after around ~1min.Output:
$ dotnet TelemetryOnReconnect.dll mqtt
IoT Hub Quickstarts #1 - Simulated device. Ctrl-C to exit. - [mqtt]
ConnectionStatusChangesHandler: status=Connected statusChangeReason=Connection_Ok count=1
8/7/19 1:45:52 AM > Sending message: {"temperature":33.5093082271094,"humidity":62.066992354610463}
8/7/19 1:45:53 AM > Sending message: {"temperature":31.004088635558304,"humidity":70.0825022114825}
8/7/19 1:45:54 AM > Sending message: {"temperature":26.698869237070376,"humidity":71.578489268002329}
8/7/19 1:45:55 AM > Sending message: {"temperature":23.296417146127865,"humidity":73.805906983933369}
8/7/19 1:45:56 AM > Sending message: {"temperature":29.586119602707271,"humidity":76.258299972982286}
ConnectionStatusChangesHandler: status=Disconnected statusChangeReason=Communication_Error count=2
ConnectionStatusChangesHandler: status=Disconnected statusChangeReason=Retry_Expired count=3
ConnectionStatusChangesHandler: status=Connected statusChangeReason=Connection_Ok count=4
8/7/19 1:47:05 AM > Sending message: {"temperature":26.741427945318364,"humidity":68.415281040787363}
8/7/19 1:47:06 AM > Sending message: {"temperature":30.122881433983743,"humidity":62.825483792845851}
8/7/19 1:47:08 AM > Sending message: {"temperature":20.885903023130215,"humidity":78.944681183874934}
8/7/19 1:47:09 AM > Sending message: {"temperature":27.157481583839974,"humidity":75.067271327165543}
8/7/19 1:47:10 AM > Sending message: {"temperature":31.124160432314575,"humidity":67.876231590228258}
I have the default retry policy enabled, which is ExponentialBackoff; with a DefaultOperationTimeout of 4mins.
I will retry this specifically with switching wifi networks, just so we cover all bases; in the meanwhile, could you provide the application logs with the below modifications:
int connectionStatusChangeCount = 0;
s_deviceClient.SetConnectionStatusChangesHandler((status, statusChangeReason) =>
{
connectionStatusChangeCount++;
Console.WriteLine($"{nameof(ConnectionStatusChangesHandler)}: status={status} statusChangeReason={statusChangeReason} count={connectionStatusChangeCount}");
});
common\test\ConsoleEventListener.cs
to your project.
b. Instantiate the listener.
private readonly ConsoleEventListener _listener = new ConsoleEventListener(new string[]{ "Microsoft-Azure-", "DotNetty-" });
Please share the logs generated with the above modifications. Thanks!
As we have not heard from you in a long time, I'm closing this issue. feel free to reopen when you have more information.
@fldvrees, @abhipsaMisra, @prmathur-microsoft, thank you for your contribution to our open-sourced project! Please help us improve by filling out this 2-minute customer satisfaction survey
Setup
Description of the issue:
The DeviceClient doens't automatically create a new connection when switching wifi network.
Scenario
Expected result
I would expect that the Azure DeviceClient automatically creates a new connection via the new available network as described here and here.
More information