-
Notifications
You must be signed in to change notification settings - Fork 177
Description
Networking is not my strong point, so I do apologise upfront if this issue sounds trivial/I'm doing anything wrong. It appears that the ports were not open. While docker-compose up succeeded, I was unable to connect to IB gateway's API (via ib_async) for further downstream usage. It appears that others had similar issues in the past, and the problem was not solved.
To replicate the issue, I used the default ib gateway compose file but edited a few things. Below is my docker-compose.yml:
name: algo-trader
services:
ib-gateway:
restart: always
build:
context: ./stable
tags:
- "ghcr.io/gnzsnz/ib-gateway:stable"
image: ghcr.io/gnzsnz/ib-gateway:stable
environment:
TWS_USERID: ib_username
TWS_PASSWORD: ib_password
TRADING_MODE: ${TRADING_MODE:-paper}
TWS_SETTINGS_PATH: ${TWS_SETTINGS_PATH:-}
READ_ONLY_API: ${READ_ONLY_API:-}
VNC_SERVER_PASSWORD: vnc_password
TWOFA_TIMEOUT_ACTION: ${TWOFA_TIMEOUT_ACTION:-exit}
BYPASS_WARNING: ${BYPASS_WARNING:-}
AUTO_RESTART_TIME: ${AUTO_RESTART_TIME:-}
AUTO_LOGOFF_TIME: ${AUTO_LOGOFF_TIME:-}
SAVE_TWS_SETTINGS: ${SAVE_TWS_SETTINGS:-}
RELOGIN_AFTER_TWOFA_TIMEOUT: ${RELOGIN_AFTER_TWOFA_TIMEOUT:-no}
TWOFA_EXIT_INTERVAL: ${TWOFA_EXIT_INTERVAL:-60}
TIME_ZONE: ${TIME_ZONE:-Etc/UTC}
TZ: ${TIME_ZONE:-Etc/UTC}
CUSTOM_CONFIG: ${CUSTOM_CONFIG:-NO}
JAVA_HEAP_SIZE: ${JAVA_HEAP_SIZE:-}
SSH_TUNNEL: ${SSH_TUNNEL:-}
SSH_OPTIONS: ${SSH_OPTIONS:-}
SSH_ALIVE_INTERVAL: ${SSH_ALIVE_INTERVAL:-}
SSH_ALIVE_COUNT: ${SSH_ALIVE_COUNT:-}
SSH_PASSPHRASE: ${SSH_PASSPHRASE:-}
SSH_REMOTE_PORT: ${SSH_REMOTE_PORT:-}
SSH_USER_TUNNEL: ${SSH_USER_TUNNEL:-}
SSH_RESTART: ${SSH_RESTART:-}
SSH_VNC_PORT: ${SSH_VNC_PORT:-}
# volumes:
# - ${PWD}/jts.ini:/home/ibgateway/Jts/jts.ini
# - ${PWD}/config.ini:/home/ibgateway/ibc/config.ini
# - ${PWD}/tws_settings/:${TWS_SETTINGS_PATH:-/home/ibgateway/Jts}
# - ${PWD}/ssh/:/home/ibgateway/.ssh
ports:
- "127.0.0.1:4002:4002" # paper
- "127.0.0.1:4001:4001" # live
- "127.0.0.1:5900:5900" # vnc
secrets:
- ib_username
- ib_password
- vnc_password
secrets:
ib_username:
file: /home/ubuntu/qtrading/creds/ib/ib_username.txt
ib_password:
file: /home/ubuntu/qtrading/creds/ib/ib_password.txt
vnc_password:
file: /home/ubuntu/qtrading/creds/ib/vnc_password.txt
I then ran docker-compose up in a EC2 instance (Ubuntu 22.04 LTS AMI, r6a.xlarge), where the container spun up successfully. Finally, I attempted telnet localhost 4002 and telnet localhost 5900, but I got a "Connection refused" error on the former. Only the latter responded correctly. (Interestingly, TightVNC couldn't find the 5900 port on the EC2 instance, so I suspect something is off there too).
I also tried this with the tws-docker-compose.yml version, but the same issue persists.