0

I am using backtrader as client with IBpy2 to access my IBC controlled IBGateway running on Docker.

I'm facing the issue that my system starts and just hangs there, with no errors or printed debug info.

I debugged my way as far as this line, reading:

self.m_serverVersion = self.m_reader.readInt()

Which is waiting to receive the server version through the connection, which never arrives.

I get this only when the IBGateway runs through docker, I don't understand how it's possible that IBpy can establish a connection but cannot exchange data.

I could not pinpoint where the problem might be, the fact that it happens only when IBC is on docker compose suggests that this depends on Docker compose, here's my docker-compose.yml file

--- updated: ---

version: '3.7'
services:
  trader:
    build: ./
    image: mytrader
    container_name: mytrader
    networks: 
      - trading
    depends_on: 
      - tws  

  tws:
    build: ./ib-docker
    image: ibconnect
    container_name: ibconnect
    ports:
      # - "4001:4001"
      - "4003:4003"
      - "5901:5901"
    volumes:
      - ./ib-docker/config.ini:/root/ibc/config.ini
      # - ./ib-docker/twsstart.sh:/opt/ibc/twsstart.sh
      - ./ib-docker/gatewaystart.sh:/opt/ibc/gatewaystart.sh
    environment:
      - TZ=UTC
      # Variables pulled from /root/IBController/IBControllerGatewayStart.sh
      - VNC_PASSWORD=password
      - IBC_PATH=/opt/ibc
      - LOG_PATH=/root/ibc/logs
    env_file:
      - tws_credentials.env
    networks: 
      - trading

networks: 
  trading: 
    driver: bridge

and the list of networks

% docker network ls
NETWORK ID          NAME                    DRIVER              SCOPE
4ad25f1cf0f4        bridge                  bridge              local
9ca6f0e3f509        giuliotrader_default    bridge              local
3afbca83e020        giuliotrader_trading    bridge              local
73c2590a3a11        host                    host                local
34e58c19f5e3        none                    null                local

happy to post any additional files or info as might be needed.

Thanks,

Don Giulio
  • 2,946
  • 3
  • 43
  • 82

1 Answers1

0

Good afternoon, maybe you should use link from trader to tws

services:
  trader:
    links:
      - tws
    build: ./
    image: mytrader
    container_name: mytrader
Colin Moreno Burgess
  • 1,432
  • 1
  • 12
  • 17
  • I originally had that, but then I re-rtfm and figured that `links` is just still there as legacy, and will be removed soon, and it's not required anymore, as docker-compose containers are by default added to the bridge network. – Don Giulio Mar 28 '19 at 13:03
  • added to the original question I also updated the docker-compose.yml file, apparently it's bad practice to use the default network, so I created one – Don Giulio Mar 28 '19 at 13:59
  • do you have any output from the cmd or whatever you are running on the containers when they start?, are you able to connect to the container if it remains up? – Colin Moreno Burgess Mar 28 '19 at 14:15
  • it just hangs there, blocking at `self.m_reader.readInt()` it's like it's not receiving data, while just before it sends its own version to the server, I'm unclear whether the connection is open at all, it's probably not. but I'm not sure how to see it, tcpdump won't work, because this traffic goes through the bridge, and not through eth0 – Don Giulio Mar 28 '19 at 14:31
  • and if I `tcpdump -i docker0` I get: `tcpdump: docker0: No such device exists (SIOCGIFHWADDR: No such device)` both in the container and the host – Don Giulio Mar 28 '19 at 14:33
  • so you can get inside the container? if thats the case with some shell you may be able to have a look to the process list on /proc and get information from fd of the pid of the process that's running your command. – Colin Moreno Burgess Mar 28 '19 at 14:54
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/190854/discussion-between-don-giulio-and-ikaro0). – Don Giulio Mar 28 '19 at 15:40