mvberg / ib-gateway-docker

Interactive Brokers Trading Gateway running in Docker
MIT License
229 stars 105 forks source link

VNC viewer connection closed unexpectedly #2

Closed mvperez closed 5 years ago

mvperez commented 6 years ago

Hi @mvberg , I'm encountering an issue to view the IB from VNC. But this problem only appears in windows. I tried several vnc viewer such as tightvnc, tigervnc, and realvnc. In MacOS I just use tightvnc and it's working fine. Here is an error I got in realvnc connecting to localhost:5901. Have you encountered this problem in Windows?

image

Update: I noticed the some errors on docker-compose up --build image

jeffreymurdock commented 6 years ago

add this into tws Dockerfile RUN sed -i -e 's/\r$//' runscript.sh RUN sed -i -e 's/\r$//' /usr/bin/xvfb-daemon-run RUN sed -i -e 's/\r$//' /etc/init.d/xvfb RUN sed -i -e 's/\r$//' /etc/init.d/vnc RUN sed -i -e 's/\r$//' /root/Jts/jts.ini RUN sed -i -e 's/\r$//' /root/IBController/IBController.ini

mvperez commented 6 years ago

Hi @jeffreymurdock , Thanks for that. I also added these two lines to add jts.ini and IBController.ini

ADD ./ib/jts.ini /root/Jts/jts.ini ADD ./ib/IBController.ini /root/IBController/IBController.ini

Save my Dockerfile and run "docker-compose up --build" again. It seems to start properly the container. But when I view TWS in VNC it seems the gateway connection repeatedly restarting (disconnected/connected status).

screen shot 2018-09-22 at 5 44 14 pm

Here's my full Dockerfile

FROM ubuntu:16.04
MAINTAINER Mike Ehrenberg <mvberg@gmail.com>

RUN  apt-get update \
  && apt-get install -y wget \
  && apt-get install -y unzip \
  && apt-get install -y xvfb \
  && apt-get install -y libxtst6 \
  && apt-get install -y libxrender1 \
  && apt-get install -y libxi6 \
    && apt-get install -y x11vnc \
  && apt-get install -y socat \
  && apt-get install -y software-properties-common

# Setup IB TWS
RUN mkdir -p /opt/TWS
WORKDIR /opt/TWS
RUN wget -q http://one-algo.s3.amazonaws.com/ibgateway-latest-standalone-linux-x64-v972.1k.sh
RUN chmod a+x ibgateway-latest-standalone-linux-x64-v972.1k.sh

# Setup  IBController
RUN mkdir -p /opt/IBController/
WORKDIR /opt/IBController/
RUN wget -q http://one-algo.s3.amazonaws.com/IBController-QuantConnect-3.2.0.zip
RUN unzip ./IBController-QuantConnect-3.2.0.zip
RUN chmod -R u+x *.sh && chmod -R u+x Scripts/*.sh

# Install Java 8 TODO maybe just use "from:java8"
RUN \
  echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | debconf-set-selections && \
  add-apt-repository -y ppa:webupd8team/java && \
  apt-get update && \
  apt-get install -y oracle-java8-installer && \
  rm -rf /var/lib/apt/lists/* && \
  rm -rf /var/cache/oracle-jdk8-installer

WORKDIR /

# Install TWS
RUN yes n | /opt/TWS/ibgateway-latest-standalone-linux-x64-v972.1k.sh

#CMD yes

# Launch a virtual screen (this seems to be broken)
#RUN Xvfb :1 -screen 0 1024x768x24 2>&1 >/dev/null &
#RUN export DISPLAY=:1

ENV DISPLAY :0

ADD runscript.sh runscript.sh
ADD ./vnc/xvfb_init /etc/init.d/xvfb
ADD ./vnc/vnc_init /etc/init.d/vnc
ADD ./vnc/xvfb-daemon-run /usr/bin/xvfb-daemon-run
ADD ./ib/jts.ini /root/Jts/jts.ini
ADD ./ib/IBController.ini /root/IBController/IBController.ini

RUN chmod -R u+x runscript.sh && chmod -R 777 /usr/bin/xvfb-daemon-run
RUN chmod 777 /etc/init.d/xvfb
RUN chmod 777 /etc/init.d/vnc

RUN sed -i -e 's/\r$//' runscript.sh
RUN sed -i -e 's/\r$//' /usr/bin/xvfb-daemon-run
RUN sed -i -e 's/\r$//' /etc/init.d/xvfb
RUN sed -i -e 's/\r$//' /etc/init.d/vnc
RUN sed -i -e 's/\r$//' /root/Jts/jts.ini
RUN sed -i -e 's/\r$//' /root/IBController/IBController.ini

CMD bash runscript.sh
mvberg commented 6 years ago

@marvinvperez

  1. hm, never had that on Windows - checking ...
  2. are you using the e-demo credentials for IB or an actual login?
mvperez commented 6 years ago

Nope. I'm using another account which is working fine in mac.

UPDATE: I think I found possible root cause here. I've learned you can't login same account at the same time. One will automatically logout. I will confirm it when I get into the machine and update this issue again.