Connect to gateway from a different machine

We are trying to connect to a gateway that we are running on QuantRocket enviroment, but from another different machine.

So we added our IP to 'Trusted IPs' list and unchecked "Allow connections from localhost only" cell.

To connect to the gateway, we use a code similar to the following:

from ib.ext.EClientSocket import EClientSocket
connection = EClientSocket(self._wrapper)
connection.eConnect('xxx.xxx.xxx.xxx', 4002, 0)

But we get a 504 error:
Couldn't connect to TWS. Confirm that "Enable ActiveX and Socket Clients" is enabled on the TWS "Configure->API" menu

Is this possible to do with QuantRocket? Are we missing any configuration?

You need to do something like this in docker-compose.override.yml:

version: '2.4'
services:
  ibg1:
    ports:
      - '4001:4001'

That maps port 4001 in the container (where IB Gateway listens) to port 4001 on the host. Then you can connect to <host_ip>:4001. You don't need to configure any IB Gateway settings or checkboxes.

1 Like

It worked. Thanks a lot!