Skip to content

Commit

Permalink
Remove PubSub MQTT startup repeat (#1547)
Browse files Browse the repository at this point in the history
This can cause considerable slowdown when connecting to multiple MQTT
destinations or when waiting for pubsub application to start, and is
unecessary.

Instead, the DisconnectHandler fires on connect fail as well, so this
implementation works.
  • Loading branch information
einarmo committed Nov 1, 2021
1 parent e72417e commit 980b9f1
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions Libraries/Opc.Ua.PubSub/Transport/MqttClientCreator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,6 @@ internal class MqttClientCreator
}
}

while (mqttClient.IsConnected == false)
{
await Connect(reconnectInterval, mqttClientOptions, mqttClient);
await Task.Delay(TimeSpan.FromSeconds(reconnectInterval)).ConfigureAwait(false);
}

// Setup reconnect handler
mqttClient.UseDisconnectedHandler(async e => {
await Task.Delay(TimeSpan.FromSeconds(reconnectInterval)).ConfigureAwait(false);
Expand All @@ -122,6 +116,8 @@ internal class MqttClientCreator
}
});

await Connect(reconnectInterval, mqttClientOptions, mqttClient);

return mqttClient;
}

Expand Down

0 comments on commit 980b9f1

Please sign in to comment.