WCF Timeout Setting

Jan 8, 2013 at 9:35 AM


Does anyone know where I can set the timeout settings for Tradeplatform.  I've noticed after long periods of inactivity, that Gateway stops receiving messages from Metatrader on the Start() event.  For it to get up and running again, I have to close and restart Gateway and Metatrader.  Failing that, is there a way to set up a heartbeat/keepalive function, like can I manually call Start() every 5 minutes or whatever to keep that connection alive?

I've found two place that offer a solution, but looking at the gateway.exe.config file, I can't figure out where to put the code.





Mar 27, 2013 at 2:09 AM
where u able to find any solutions?
Mar 27, 2013 at 8:17 AM

Yes I did. For that specific problem, I set up a timer to ping the WCF server every few minutes. Here's a snippet of the code, timer and _WCFClient are global variables, I know that's naughty but I have my reasons:
    private void StartTimer()
            timer = new System.Threading.Timer(new TimerCallback(DoSomething), null, 0, 120000); 
        catch (Exception err)
             //just some error handling code
            using (StreamWriter sw = new StreamWriter(@"C:\ATS\ERRORLOGS\FrmSymbolTimer.txt", true))
                sw.WriteLine("\n" + DateTime.Now.ToString() +
                    "\n*** FrmSymbol StartTimer() ***" +
                    "\nError: " + err.ToString() +

    private void DoSomething(object obj)
       _WCFclient.SendMessage("TM-" + pSymbol, "all", "PING");
The above was my second solution, for my first solution, I wrote an autoit3 script and used System Scheduler to shut down and restart Gateway and MT4 and all my clients every hour or so. It was a pretty easy solution, but it became a bit annoying after a while, so the above solution worked out better for me, except every now and then I'd get weird memory errors. So I ended up using a combination of these two, I'd have the ping run every few minutes, then I'd set the autoit3 script to run at like 4 in the morning to shut down and restart everything.

Ultimately, I've actually stopped using TradePlatform and I'm using Interop to create dlls for Metatrader. The drawback is I had to learn some MQL4 (which is what I was trying to avoid), but to write the basic functions to interact with my dll, it wasn't too bad, so it's worked out for me.

Hope I could help.