How to deal with dead Testing Agent instances?

 

I have my local agent farm with ~200 agents.

Every now and them some of  the agents stop accepting new work, and the only solution is to restart them.



From the MT5 terminal I can see that some of these agents appear as "Occupied by another terminal" - This information is not correct, however, as I can check that they are completely idle in their host machine.


It seems that the agent will silently crash and stays in this condition until restarted. This can be quite frustrating as it's happening multiple times a day.

I tried to write a watchdog script for automatically restarting the agents, but I am running into some problems:

A simple TCP check to the agent port is not enough; sometimes the TCP connection can be established to the agent, but that doesn't mean that the agent is alive;

A better cenario would be to create a script that simulates a handshake with the agent, however the testing agent protocol seems to be something encrypted.


Is anyone else facing the same issue and come up with a better solution?

MetaTrader Strategy Tester Watchdog (Native Windows version)
MetaTrader Strategy Tester Watchdog (Native Windows version)
  • gist.github.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters