mvberg / ib-gateway-docker

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

Force disconnecting a client connection inside IB gateway #7

Open mvperez opened 5 years ago

mvperez commented 5 years ago

Hi,

Thanks for updating the IBG version! Does anyone encounter a scenario where a client connection does not disconnect when you close the application? Then the next time I restart the application I could not connect properly because I am using the same client Id. I don't want to change the client Id. The client application which is connecting to IBG is asp.net core web api. The connection will happen automatically during the start of the application.

My setup was -

  1. ib-gateway-docker is run in Linux VM, expose the port. Access is limited to specific IP only.
  2. asp.net core web api deploy separately in Azure (using docker-compose). This web api can connect to ib-gateway-docker
  3. web application deployed in Azure (using docker-compose together with #2). This web application accessing ther web api (#2)

Everything is working fine on the first deployment. Then web api to IB gateway just stop functioning even if it shows the client id still connected in VNC. Then later on VNC will hang and couldn't reconnect.

Is there any way I can see the full logs inside the docker? Is there a way to forcefully disconnect the client id without shutting down the docker container?

Thanks, Marvin

krumware commented 5 years ago

Haven't had any similar trouble in this end with the freezing, but you should be able to run and attach to the container to see the log output, or do a volume mount to mount a local directory to the specified logging directory in the container. I'm not aware of a way to force disconnect besides restarting the gateway container.

mvperez commented 5 years ago

Yeah, I think the problem was that the client (which is the web api) losing the connection somehow but the other problem was that the IBG is not disconnecting the client. Once my web api started, a connection is established to IBG and I'd like to keep it open until I issue disconnect. If I leave the web api idle for few minutes the IB signal and reader are not working anymore (maybe a crash in the background thread), though I can still send the request to IBG. Because of this, IBG showing there's still an open client connection and I can't disconnect it, thus leaving it idle. And yes, there's no way but to restart IBG. Even if I shutdown the web api it didn't close the connection.

krumware commented 5 years ago

I've seen something similar to this, but where the gateway seems to not be getting updated values from IB, just returning the same account values to the client over and over. I'm not sure if they are related, and it likely isn't the host container, but I'm watching it. Proactive restarts of IB Gateway seem to be necessary at this point as well.