question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ZeroMQ Connector failed to read response from server when compiled into a program

See original GitHub issue

I was following the 7 video tutorial on how to interface python with metatrader 4 and got no problem running them on iPython kernel By no problem I mean a trade was sent to the server with ease and client (my laptop) received proper response after each action is executed. When I call zmq._get_response_() I can get access to server response.

The problem starts to arise when I want to compile the DWX_ZeroMQ_Connector class within a program. So I start with a simple program just like this :

def main():  
zmq = DWX_ZeroMQ_Connector()
my_trade = { '_action':       'OPEN',
             '_type':         0,
             '_symbol':       'USOIL',
             '_price':        0.0,
             '_SL':           0,
             '_TP':           0,
             '_comment':      'dwx-zeromq',
             '_lots':         0.01,
             '_magic':   123456,
             '_ticket':       0
             }

zmq._DWX_MTX_NEW_TRADE_(_order=my_trade)

reply = zmq._get_response_()  
all_trade = zmq._DWX_MTX_GET_ALL_OPEN_TRADES_()
print("reply" + str(reply))
print("----------------------")
print("alltrade"+ str(all_trade))

main() 

his script STILL SENDS ORDERS SUCCESSFULLY, BUT DID NOT PROMPT ANY RESPONSE BACK as the reply turned out to be null. As I could get response and send data back and forth using ipython console, I guess you could eliminate dependencies as source of problem. Already installed the VC++ libraries from 2017.

A more comprehensive description of my issues can be found here, where I also showed my printed version in the console, logs of both MT4 Terminal and Experts and etc.

Please do not hesisitate asking me to send any additional information as I was struggling with this for quite a while. Cheers

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10

github_iconTop GitHub Comments

1reaction
hoangson0409commented, Apr 19, 2020

Hey, Refer this link for possible solution. You will not get response as soon as request send. Response will be delayed. So does your code should wait until you get response back. #67 (comment)

Hi @SpideyAntman, could you kindly point out how can I fix my code in this case ? The example given was probably from an older version and I could not find methods that was used in the example. So far I have tried adding

while zmq._ACTIVE == True:
           
            reply = zmq._get_response_()  
            all_trade = zmq._DWX_MTX_GET_ALL_OPEN_TRADES_()
            print("reply" + str(reply))
            print("----------------------")
            print("alltrade"+ str(all_trade))
            print(reply == None)
            print(all_trade == None)

This doesnt seem to work

And also tried using async function

async def main():  

   zmq = DWX_ZeroMQ_Connector()
   my_trade = { '_action':       'OPEN',
             '_type':         0,
             '_symbol':       'USOIL',
             '_price':        0.0,
             '_SL':           0,
             '_TP':           0,
             '_comment':      'dwx-zeromq',
             '_lots':         0.01,
             '_magic':   123456,
             '_ticket':       0
             }

   zmq._DWX_MTX_NEW_TRADE_(_order=my_trade)

   reply = await zmq._get_response_()  
   all_trade = zmq._DWX_MTX_GET_ALL_OPEN_TRADES_()
   print("reply" + str(reply))
   print("----------------------")
   print("alltrade"+ str(all_trade))

main() 

Ah and this would not work too

0reactions
elvinexcommented, Oct 27, 2021

Thank you, I’m glad we were able to solve this. 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

ZeroMQ Connector still sent data successfully but failed to get ...
When I call zmq._get_response_() I can get access to server response. The problem starts to arise when I want to compile the ...
Read more >
Get started - ZeroMQ
The server creates a socket of type response (you will read more about request-response later), binds it to port 5555 and then waits...
Read more >
Chapter 3 - Advanced Request-Reply Patterns - ZeroMQ Guide
Incidentally the REP socket can only deal with one request-reply exchange at a time, which is why if you try to read multiple...
Read more >
1. Basics | ØMQ - ZeroMQ Guide
The server binds its REP (reply) socket to port 5555. The server waits for a request in a loop, and responds each time...
Read more >
7. Advanced Architecture using ZeroMQ | ØMQ - The Guide
Chapter 7 - Advanced Architecture using ZeroMQ # One of the effects of using ZeroMQ at large scale is that because we can...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found