Click or drag to resize


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:

  1. It is impossible to establish a connection (no connection, incorrect login-password, etc.). The number of attempts to establish a connection is set through the ReConnectionSettingsAttemptCount property. The default is 0, meaning that the mode is disabled. -1 specifies an infinite number of attempts.
  2. The connection was broken during the working process. The number of attempts to reestablish a connection is set through the ReConnectionSettingsReAttemptCount property. The default is 100. -1 specifies an infinite number of attempts. 0 – the mode is disabled.

Use of the connection tracking

  1. 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()));
  2. In order to check how the mechanism works, it is possible, for example, turn off your Internet connection:

    Внешние транзакции.

  3. The program will signal about loss of connection:

    Connection lost.

  4. Once the external transactions turned on, the program will display a message about the successful reconnection:

    Connection restored.