The Connector class realizes in its code the connections monitoring. Such a tracking is configured through the ConnectorReConnectionSettings property and allows to track the following error scenarios:
For the demonstration the SampleOEC example working with OpenECry is taken.
When creating a gateway, it is necessary to initialize the reconnections mechanism settings through the ConnectorReConnectionSettings property:
// tradking interval is 10 seconds Trader.ReConnectionSettings.Interval = TimeSpan.FromSeconds(10); Trader.ReConnectionSettings.ConnectionRestored += () => this.GuiAsync(() => MessageBox.Show(this, "Connection was restored.")); // connection was dropped Trader.ConnectionError += error => this.Sync(() => MessageBox.Show(this, error.ToString()));
In order to check how the mechanism works, it is possible, for example, turn off your Internet connection:
The program will signal about loss of connection:
Once the external transactions turned on, the program will display a message about the successful reconnection: