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

Remote connecting to VPS from local machine #77

Closed jehung closed 3 years ago

jehung commented 4 years ago

Hi, I have a remote server on which my MT4 terminal sits. I am trying to connect to it from my local computer. I have followed your instructions listed in your readme and if i try to run the python client from my computer (notably changing the _host variable in the DWX_ZeroMQ_Connector_v2_0_1_RC8.py file like this:

class DWX_ZeroMQ_Connector(): """ Setup ZeroMQ -> MetaTrader Connector """

    def __init__(self,
                 _ClientID='dwx-zeromq',  # Unique ID for this client
                 _host='<my VPS's external IP>,  # Host to connect to
                 _protocol='tcp',  # Connection protocol
                 _PUSH_PORT=32768,  # Port for Sending commands
                 _PULL_PORT=32769,  # Port for Receiving responses
                 _SUB_PORT=32770,  # Port for Subscribing for prices
                 _delimiter=';',
                 _verbose=True,  # String delimiter
                 _poll_timeout=1000,  # ZMQ Poller Timeout (ms)
                 _sleep_delay=0.001,  # 1 ms for time.sleep()
                 _monitor=False):  # Experimental ZeroMQ Socket Monitoring

        ######################################################################

of the client to the VPS IPv4 elastic public ip) it gives me the following error.

[INIT] Ready to send commands to METATRADER (PUSH): 32768
[INIT] Listening for responses from METATRADER (PULL): 32769
[INIT] Listening for market data from METATRADER (SUB): 32770
[EURUSD_Trader] Alright, here we go.. Gerrrronimooooooooooo! ..... xD

+--------------+

LIVE UPDATES +
+--------------+
Resource timeout.. please try again. Failed to send commands.

However, if i run the same client on the VPS itself, changing the same variable _host to 127.0.0.1, then it works fine and creates trades etc...

What am I missing? Please hep! Thanks!

feliux commented 3 years ago

Hi @jehung,

I had the same problem but I solved after review my firewall rules. If you are using a Linux system you can run on your VPS something like $ sudo ufw allow proto tcp from <YOUR_IP> to any port <PULL_PORT>.