Skip to content

Issue connecting to IB Gateway or TWS on Remote Host #212

Description

@amateurbutinterested

I have had the following issue. I install the IB Gateway in another server in my LAN. There is no firewall installed. I setup the API and allow the connection from my client computer. (I add the IP address to the trusted IPs in the Gateway Settings).

I am able to telnet from my client machine to the gateway API port.

I look to connect and I get the following error --

API connection failed: TimeoutError()
Traceback (most recent call last):
  File "manage.py", line 21, in <module>
    main()
  File "manage.py", line 17, in main
    execute_from_command_line(sys.argv)
  File "/Users/monte.davis/.venvs/scorecard/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/Users/monte.davis/.venvs/scorecard/lib/python3.7/site-packages/django/core/management/__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/monte.davis/.venvs/scorecard/lib/python3.7/site-packages/django/core/management/base.py", line 323, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/Users/monte.davis/.venvs/scorecard/lib/python3.7/site-packages/django/core/management/base.py", line 364, in execute
    output = self.handle(*args, **options)
  File "/Users/monte.davis/src/scorecard/securities/management/commands/liveprices.py", line 16, in handle
    ib.connect(settings.IB_API_URL,settings.IB_API_PORT,clientId=2)
  File "/Users/monte.davis/.venvs/scorecard/lib/python3.7/site-packages/ib_insync/ib.py", line 230, in connect
    host, port, clientId, timeout, readonly))
  File "/Users/monte.davis/.venvs/scorecard/lib/python3.7/site-packages/ib_insync/ib.py", line 263, in _run
    return util.run(*awaitables, timeout=self.RequestTimeout)
  File "/Users/monte.davis/.venvs/scorecard/lib/python3.7/site-packages/ib_insync/util.py", line 253, in run
    raise globalErrorEvent.value() or e
  File "/Users/monte.davis/.venvs/scorecard/lib/python3.7/site-packages/ib_insync/util.py", line 251, in run
    result = loop.run_until_complete(task)
  File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete
    return future.result()
concurrent.futures._base.CancelledError

I have tested with both TWS and IB Gateway latest stable version. The only test that I have not run is with the native python API from IB.

The code works perfectly in localhost.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions