gmag11 / MetaTrader5-Docker-Image

Docker image that runs Metatrader 5 with VNC web server
MIT License
107 stars 51 forks source link

IPC timeout #15

Open luismasuelli opened 1 month ago

luismasuelli commented 1 month ago

Steps to reproduce:

  1. Cloning the repository:
git clone https://github.com/gmag11/MetaTrader5-Docker-Image
  1. Inside the repository, build the image:
cd MetaTrader5-Docker-Image
docker build -t mt5
cd ..
  1. Use this compose file (the local image is tagged: mt5 - create as my-compose-file.yml):
version: '3'
services:
  mt5:
    image: mt5
    container_name: mt5
    volumes:
      - ./config:/config
    ports:
      - "3000:3000"
      - "8001:8001"
  1. launch the compose file:
docker compose -f my-compose-file.yaml up
  1. In the host machine, considering 8001 is exposed, use python3:

This is the code I try in Python (in my host machine).

from mt5linux import MetaTrader5
mt5 = MetaTrader5(host='192.168.my.ip',port=8001)
mt5.initialize()

Result:

mt5.initialize() returns False after a long time, and nothing is initialized. mt5.last_error() returns (-10005, "IPC timeout"). mt5.version() returns an empty result.

I expect:

Everything to work fine.

luismasuelli commented 1 month ago

In fact, let's get rid of any complexity.

  1. Launch the image however you want. It will report port 8001 is listening.
  2. Dive into the container (e.g. docker-compose exec ... or docker compose exec ... or docker exec ... depending on how you launched it).
  3. Open a python terminal.
from mt5linux import MetaTrader5
mt5 = MetaTrader5(host='127.0.0.1',port=8001)
mt5.initialize()

Either the same will happen or instead this error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/config/.local/lib/python3.9/site-packages/mt5linux/__init__.py", line 464, in initialize
    return self.__conn.eval(code)
  File "/config/.local/lib/python3.9/site-packages/rpyc/core/netref.py", line 240, in __call__
    return syncreq(_self, consts.HANDLE_CALL, args, kwargs)
  File "/config/.local/lib/python3.9/site-packages/rpyc/core/netref.py", line 63, in syncreq
    return conn.sync_request(handler, proxy, *args)
  File "/config/.local/lib/python3.9/site-packages/rpyc/core/protocol.py", line 473, in sync_request
    return self.async_request(handler, *args, timeout=timeout).value
  File "/config/.local/lib/python3.9/site-packages/rpyc/core/async_.py", line 100, in value
    self.wait()
  File "/config/.local/lib/python3.9/site-packages/rpyc/core/async_.py", line 49, in wait
    raise AsyncResultTimeout("result expired")
TimeoutError: result expired
caiusCitiriga commented 1 week ago

same here