0
Geplant

No automatic ADS reconnection after TwinCAT PLC reboot

Ramon Janousch Vor 20 Stunden in realvirtual.io Starter and Professional aktualisiert von Support Vor 18 Stunden 0

Hi,

we use realvirtual's TwinCatAdsInterface to communicate with a TwinCAT PLC.

When the PLC reboots, the ADS connection is lost. We receive the anticipated connection-loss error message and all stages move into their configured default positions. However, once the PLC is available again, our application does not reconnect automatically. Normal operation is restored only after restarting our application.

Another application (C# .NET app which is also using the ADS library) connected to the same PLC is able to reconnect successfully after the PLC reboot.
If we use a simulated PLC, the real-virtual interface can reestablish the connection, the problem only occurs when we work with a real PLC.

Environment:

- Unity: 6000.3.22f1

- realvirtual Professional: 6.3.5

- realvirtual Starter: 6.3.5

- TwinCAT/PLC version: v3.1.4026.14

- ADS port: 851

- Update cycle: 100 ms

Steps to reproduce:

1.Establish communication with a real PLC.

2. Confirm normal operation.

3. Reboot the PLC or restart the TwinCAT runtime.

4. Wait until the PLC is available again.

5. Observe the ADS connection without restarting our application.

Expected result:

The TwinCatAdsInterface reconnects automatically after the PLC becomes available again.

Actual result:

The connection-loss error is reported and the stages move to their default positions, but the ADS connection is not restored. Restarting our application is required.

Could you please advise whether a specific reconnect configuration or API call is required, and whether this behavior is a known issue in realvirtual 6.3.5?

Geplant

Hi Ramon,


thank you for the detailed bug report including environment details and reproduction steps.


We have investigated the behavior in the code and can confirm this is a bug in realvirtual 6.3.5.


**Root cause:** The automatic reconnect in `TwinCatAdsInterface` relies on the `AmsRouterNotification` event, which fires when the *local* TwinCAT AMS router service changes state (Stop/Start). When a simulated PLC (TwinCAT XAE runtime on the same machine) is restarted, the local router cycles through "Stop" which triggers the reconnect loop. When a *physical PLC* reboots, the local AMS router stays running — no "Stop" event fires, so the reconnect logic never activates, even though the ADS connection is broken.


**Workaround (until a fix is released):** You can implement a small MonoBehaviour that monitors `TwinCatAdsInterface.ConnectionStatus` and calls `OpenInterface()` manually when a disconnection is detected:


```csharp


public class TwinCatReconnectHelper : MonoBehaviour


{


public TwinCatAdsInterface adsInterface;


private bool wasConnected = false;


void Update()


{


bool isConnected = adsInterface.IsConnected;


if (wasConnected && !isConnected)


{


// connection lost — try to reconnect


adsInterface.OpenInterface();


}


wasConnected = isConnected;


}


}


```


Note: `OpenInterface()` already includes a 1-second retry throttle (`_lastreconnect`), so calling it repeatedly is safe. You may want to add your own cooldown on top.


We will track this internally and address the root cause in a future update so that ADS-level connection loss (not just local router transitions) triggers the reconnect automatically.


Best regards,


realvirtual Support