Inconsistent slower API response and disconnect.
The issue reported at #242 seems to persist. Typically, I query more than 20 tickers' historical data with a period of 30 days and a frequency of 5 minutes. However, I've noticed that some of the queries are significantly slower than usual, eventually leading to errors when the gateway disconnects, with the following error being displayed from gateway output.
Connection timeout after 15 seconds. Consider increasing timeout by setting IBEAM_REQUEST_TIMEOUT environment variable. Error: The read operation timed out
2025-03-26 21:14:16 2025-03-26 21:14:16,458|I| Max request retries reached after 2 attempts. Consider increasing the retries by setting IBEAM_REQUEST_RETRIES environment variable
2025-03-26 21:14:16 2025-03-26 21:14:16,458|I| NO SESSION Status(running=True, session=False, connected=False, authenticated=False, competing=False, collision=False, session_id=None, server_name=None, server_version=None, expires=None)
2025-03-26 21:14:16 2025-03-26 21:14:16,458|I| Authentication strategy: "B"
2025-03-26 21:14:16 2025-03-26 21:14:16,458|I| No active sessions, logging in...
2025-03-26 21:14:16 2025-03-26 21:14:16,458|I| Loading auth webpage at https://localhost:5000/sso/Login?forwardTo=22&RL=1&ip2loc=on
2025-03-26 21:14:16 2025-03-26 21:14:16,458|E| Connection timeout after 15 seconds. Consider increasing timeout by setting IBEAM_REQUEST_TIMEOUT environment variable. Error: The read operation timed out
2025-03-26 21:14:37 2025-03-26 21:14:37,178|E| Timeout reached when waiting for authentication. The website seems to not be loaded correctly. Consider increasing IBEAM_PAGE_LOAD_TIMEOUT.
2025-03-26 21:14:37 Website URL: https://localhost:5000/sso/Login?forwardTo=22&RL=1&ip2loc=on
2025-03-26 21:14:37
2025-03-26 21:14:37 Exception:
2025-03-26 21:14:37 File "/usr/local/lib/python3.11/threading.py", line 995, in _bootstrap
2025-03-26 21:14:37 self._bootstrap_inner()
2025-03-26 21:14:37 File "/usr/local/lib/python3.11/threading.py", line 1038, in _bootstrap_inner
2025-03-26 21:14:37 self.run()
2025-03-26 21:14:37 File "/usr/local/lib/python3.11/threading.py", line 975, in run
2025-03-26 21:14:37 self._target(*self._args, **self._kwargs)
2025-03-26 21:14:37 File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 83, in _worker
2025-03-26 21:14:37 work_item.run()
2025-03-26 21:14:37 File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
2025-03-26 21:14:37 result = self.fn(*self.args, **self.kwargs)
2025-03-26 21:14:37 File "/opt/venv/lib/python3.11/site-packages/apscheduler/executors/base.py", line 125, in run_job
2025-03-26 21:14:37 retval = job.func(*job.args, **job.kwargs)
2025-03-26 21:14:37 File "/srv/ibeam/src/gateway_client.py", line 115, in _maintenance
2025-03-26 21:14:37 success, shutdown, status = self.start_and_authenticate(request_retries=self.request_retries)
2025-03-26 21:14:37 File "/srv/ibeam/src/gateway_client.py", line 62, in start_and_authenticate
2025-03-26 21:14:37 success, shutdown, status = self.strategy_handler.try_authenticating(request_retries=request_retries)
2025-03-26 21:14:37 File "/srv/ibeam/src/handlers/strategy_handler.py", line 85, in try_authenticating
2025-03-26 21:14:37 return self._authentication_strategy_B(status, request_retries)
2025-03-26 21:14:37 File "/srv/ibeam/src/handlers/strategy_handler.py", line 140, in _authentication_strategy_B
2025-03-26 21:14:37 return self._log_in(status)
2025-03-26 21:14:37 File "/srv/ibeam/src/handlers/strategy_handler.py", line 151, in _log_in
2025-03-26 21:14:37 success, shutdown = self.login_handler.login()
2025-03-26 21:14:37 File "/srv/ibeam/src/handlers/login_handler.py", line 504, in login
2025-03-26 21:14:37 self.handle_timeout_exception(e, targets, driver, website_version, self.route_auth, self.base_url, self.outputs_dir)
2025-03-26 21:14:37 File "/srv/ibeam/src/handlers/login_handler.py", line 470, in login
2025-03-26 21:14:37 wait_and_identify_trigger = self.load_page(targets, driver, self.base_url, self.route_auth)
2025-03-26 21:14:37 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-03-26 21:14:37 File "/srv/ibeam/src/handlers/login_handler.py", line 433, in load_page
2025-03-26 21:14:37 driver.get(base_url + route_auth)
2025-03-26 21:14:37 File "/opt/venv/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py", line 353, in get
2025-03-26 21:14:37 self.execute(Command.GET, {"url": url})
2025-03-26 21:14:37 File "/opt/venv/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py", line 344, in execute
2025-03-26 21:14:37 self.error_handler.check_response(response)
2025-03-26 21:14:37 File "/opt/venv/lib/python3.11/site-packages/selenium/webdriver/remote/errorhandler.py", line 229, in check_response
2025-03-26 21:14:37 raise exception_class(message, screen, stacktrace)
2025-03-26 21:14:37
2025-03-26 21:14:37 <class 'selenium.common.exceptions.TimeoutException'> Message: timeout: Timed out receiving message from renderer: -0.001
2025-03-26 21:14:37 (Session info: chrome-headless-shell=120.0.6099.224)
2025-03-26 21:14:37 Stacktrace:
2025-03-26 21:14:37 #0 0x55a9a1e59233
hey @lth98 thanks for describing your issue in details 👍
My first guess would be that there are some connectivity issues between the Gateway and the IBKR:
- your requests slow down
- your requests stop working
- several IBeam requests fail too, hence it considers there is no active sesison
- It tries to load the Gateway webpage to log in again
- The webpage load times out
All seems to point at some connectivity issue with IBKR.
- Where do you have it deployed - locally or on cloud?
- Have you contacted IBKR support regarding the slowdowns and the disconnects?
Also, note that although you've posted there too, the other issue you linked is unrelated to what you're experiencing here.
I am having this issue too.