Peer disable by script does not work as clicking

Hello everybody,
I know that this could be a strange topic but we are observing the following strange behavior.

We have many HW devices connected via VPN using wireguard, sometimes (we do not know why) they loose the connection with the Mikrotik, the only way to restore is to disable and enable the peer.

So we wrote a script that disable, wait 3 secs and enable the peer which are disconnected, but this does not always work. The only way is manually click on the peer button (using winbox) to disable and enable again.

Seems that the disable and enable functions works differently if clicked form Winbox other than from script.
One important note, during the script execution I can see that the Peers go disable and enable (they turn grey)

Someone has an idea ??

Many thanks
Pietro

If I was to guess, it doesn’t work because the “issue” is at the other side, it isn’t down long enough for the session to re-establish.

Without seeing your configurations, try the “keep-alive” parameter.

How do you trigger the script to enable/disable? Is it automated? Do you know why it stops working?