darwinex / dwx-zeromq-connector

Wrapper library for algorithmic trading in Python 3, providing DMA/STP access to Darwinex liquidity via a ZeroMQ-enabled MetaTrader Bridge EA.
https://blog.darwinex.com/zeromq-interface-python-r-metatrader4/
BSD 3-Clause "New" or "Revised" License
342 stars 227 forks source link

ZMQ Pub Socket send - Losing data #76

Closed brunobuger closed 4 years ago

brunobuger commented 4 years ago

Hi guys, I created a new method to get TimesAndSales and send through pub socket, this method is called by OnTick(I also tried to use OnTimer too) and before each message be sent(InformPullClient call) I'm printing the log of the information that will be sent, but a lot of messages are being printed but were not sent. After some network analysis and many tests on the code, I identified that it is a problem of thread competition, only works when I put a high Sleep or when I run via Script mode (It seems that in this mode it is totally synchronous) .. I also implemented a Mutex to lock and control the flow but didn't work. Any idea?

void InformPullClient(Socket& pSocket, string message)
  {

   Print(message);
   ZmqMsg pushReply(StringFormat("%s", message));

   pSocket.send(pushReply,true); // NON-BLOCKING

  }