Download MetaTrader 5
To add comments, please log in or register
You sell neither signals nor apps? No problem, everyone can make profit!
gianks 2011.05.26 22:29 


i've been fighting for two weeks with a very strange network problem.

I've wrote a DLL to use sockets with my EA wich connects to a remote server and then starts sending out every price update. No problem at this stage.

Since i'd like the EA to work even with the strategy tester, i've developed a communication protocol between the client/server to allow the server to send an explicit request for a price update, wich causes the onTick function in the EA to return, to allow the tester to provide a new cicle ( in the real time mode the onTick function simply never returns, always checking if prices are changed and taking proper actions ).

So, while in testing, after sending the new prices, the EA, via DLL, calls the recv() winsock functions, starting waiting for a well formatted "PRICE UPDATE REQUEST" (or, precisely, for a network event). 

This is a network capture example:

      EA     => SERVER (NEW PRICES)


      EA     => SERVER (NEW PRICES)

      AND SO ON...........

Here the problem raises:

After hundreds of well working cicles, the client hangs in receiving data from the socket ( the recv() function doesn't return anymore ).

Looking at a real network capture, is possible to see that in the last cicle, the server retransmits the TCP packet due to the missing acknowledge from the client, then the client sends back an ACK package.

No more data will be sent from the client, wich stalls and start waiting forever, without any reason.

The most funny thing is related to the speed: grater speeds lead to early failure.

I've tried with a variable delay after every cicle: increasing the amount of time, the number of well done cycles reaches a max value.

The last remark:

when the client hangs, the only way i've found to make the recv() function to return is to close the server application, closing the connection. At that moment, the client start running again.

Please, help me to find out what's happening here... it seems to be Computer Magic!

Thanks to all



To add comments, please log in or register