Closed Voyz closed 1 year ago
Here are the logs from my first attempt at using strategy B:
Attaching to ibeam ibeam | WARNING: All illegal access operations will be denied in a future release ibeam | 2023-06-29 16:28:35,793|I| Cannot ping Gateway. Retrying for another 19 seconds ibeam | -> mount demo on /demo ibeam | Java Version: 11.0.18 ibeam | **** ibeam | version: 485dc2d762781c4ff3954ac4fb66a9469a1405f7 Mon, 20 Mar 2023 14:39:35 -0400 ibeam | **** ibeam | This is the Client Portal Gateway ibeam | for any issues, please contact api@ibkr.com ibeam | and include a copy of your logs ibeam | **** ibeam | https://www.interactivebrokers.com/api/doc.html ibeam | **** ibeam | Open https://localhost:5000 to login ibeam | App demo is available after you login under: https://localhost:5000/demo#/ ibeam | 2023-06-29 16:28:37,483|I| Gateway connection established ibeam | 2023-06-29 16:28:37,816|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) ibeam | 2023-06-29 16:28:37,816|I| Authentication strategy: "B" ibeam | 2023-06-29 16:28:37,816|I| No active sessions, logging in... ibeam | 2023-06-29 16:28:37,816|I| Loading auth webpage at https://localhost:5000/sso/Login?forwardTo=22&RL=1&ip2loc=on ibeam | 2023-06-29 16:28:47,330|I| Gateway auth webpage loaded ibeam | 2023-06-29 16:28:47,330|I| Login attempt number 1 ibeam | 2023-06-29 16:28:52,689|I| Submitting the form ibeam | 2023-06-29 16:29:03,151|I| Webpage displayed "Client login succeeds" ibeam | 2023-06-29 16:29:05,151|I| Cleaning up the resources. Display: <pyvirtualdisplay.display.Display object at 0x7f19761c73d0> | Driver: <selenium.webdriver.chrome.webdriver.WebDriver (session="34f3177e6b18ad0f5eebac5774f1ab7e")> ibeam | 2023-06-29 16:29:05,204|I| Logging in succeeded ibeam | 2023-06-29 16:29:06,337|I| Repeating status check attempts another 14 times ibeam | 2023-06-29 16:29:21,927|I| Max status check retries reached after 15 attempts. Consider increasing the retries by setting IBEAM_MAX_STATUS_CHECK_ATTEMPTS environment variable ibeam | 2023-06-29 16:29:21,928|I| NOT CONNECTED Status(running=True, session=True, connected=False, authenticated=False, competing=False, collision=False, session_id='85cab2bd4a8505681028c4664a9dd510', server_name=None, server_version=None, expires=581466) ibeam | 2023-06-29 16:29:21,954|I| Repeated reauthentication attempt number 2 ibeam | 2023-06-29 16:29:23,103|I| Repeating status check attempts another 14 times ibeam | 2023-06-29 16:29:38,446|I| Max status check retries reached after 15 attempts. Consider increasing the retries by setting IBEAM_MAX_STATUS_CHECK_ATTEMPTS environment variable ibeam | 2023-06-29 16:29:38,446|I| NOT CONNECTED Status(running=True, session=True, connected=False, authenticated=False, competing=False, collision=False, session_id='85cab2bd4a8505681028c4664a9dd510', server_name=None, server_version=None, expires=564917) ibeam | 2023-06-29 16:29:38,462|I| Repeated reauthentication attempt number 3 ibeam | 2023-06-29 16:29:39,638|I| Repeating status check attempts another 14 times ibeam | 2023-06-29 16:29:55,207|I| Max status check retries reached after 15 attempts. Consider increasing the retries by setting IBEAM_MAX_STATUS_CHECK_ATTEMPTS environment variable ibeam | 2023-06-29 16:29:55,207|I| NOT CONNECTED Status(running=True, session=True, connected=False, authenticated=False, competing=False, collision=False, session_id='85cab2bd4a8505681028c4664a9dd510', server_name=None, server_version=None, expires=548161) ibeam | 2023-06-29 16:29:55,221|I| Repeated reauthentication attempt number 4 ibeam | 2023-06-29 16:29:56,384|I| Repeating status check attempts another 14 times ibeam | 2023-06-29 16:30:11,883|I| Max status check retries reached after 15 attempts. Consider increasing the retries by setting IBEAM_MAX_STATUS_CHECK_ATTEMPTS environment variable ibeam | 2023-06-29 16:30:11,883|I| NOT CONNECTED Status(running=True, session=True, connected=False, authenticated=False, competing=False, collision=False, session_id='85cab2bd4a8505681028c4664a9dd510', server_name=None, server_version=None, expires=531485) ibeam | 2023-06-29 16:30:11,898|I| Repeated reauthentication attempt number 5 ibeam | 2023-06-29 16:30:13,043|I| Repeating status check attempts another 14 times ibeam | 2023-06-29 16:30:28,386|I| Max status check retries reached after 15 attempts. Consider increasing the retries by setting IBEAM_MAX_STATUS_CHECK_ATTEMPTS environment variable ibeam | 2023-06-29 16:30:28,386|I| NOT CONNECTED Status(running=True, session=True, connected=False, authenticated=False, competing=False, collision=False, session_id='85cab2bd4a8505681028c4664a9dd510', server_name=None, server_version=None, expires=514991) ibeam | 2023-06-29 16:30:28,387|I| Max reauthenticate retries reached after 5 attempts. Consider increasing the retries by setting IBEAM_MAX_REAUTHENTICATE_RETRIES environment variable ibeam | 2023-06-29 16:30:28,387|E| Repeatedly reauthenticating failed 5 times. Killing the Gateway and restarting the authentication process. ibeam | 2023-06-29 16:30:29,394|I| Starting maintenance with interval 60 seconds
After the maintenance interval:
ibeam | 2023-06-29 16:31:32,801|I| Authentication strategy: "B" ibeam | 2023-06-29 16:31:32,801|I| Loading auth webpage at https://localhost:5000/sso/Login?forwardTo=22&RL=1&ip2loc=on ibeam | 2023-06-29 16:31:39,948|I| Gateway auth webpage loaded ibeam | 2023-06-29 16:31:39,948|I| Login attempt number 1 ibeam | 2023-06-29 16:31:45,301|I| Submitting the form ibeam | 2023-06-29 16:32:00,901|E| Timeout reached searching for website elements, but the website seems to be loaded correctly. It is possible the setup is incorrect. ibeam | Website version: 2 ibeam | DOM elements searched for: {'USER_NAME_EL': 'username', 'PASSWORD_EL': 'password', 'SUBMIT_EL': 'button.btn.btn-lg.btn-primary', 'ERROR_EL': 'xyz-errormessage', 'SUCCESS_EL_TEXT': 'Client login succeeds', 'IBKEY_PROMO_EL_CLASS': 'ibkey-promo-skip', 'TWO_FA_EL_ID': 'twofactbase', 'TWO_FA_NOTIFICATION_EL': 'login-step-notification', 'TWO_FA_INPUT_EL_ID': 'chlginput', 'TWO_FA_SELECT_EL_ID': 'sf_select'}. ibeam | Exception: ibeam | File "/usr/local/lib/python3.11/threading.py", line 995, in _bootstrap ibeam | self._bootstrap_inner() ibeam | File "/usr/local/lib/python3.11/threading.py", line 1038, in _bootstrap_inner ibeam | self.run() ibeam | File "/usr/local/lib/python3.11/threading.py", line 975, in run ibeam | self._target(*self._args, self._kwargs) ibeam | File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 83, in _worker ibeam | work_item.run() ibeam | File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run ibeam | result = self.fn(*self.args, *self.kwargs) ibeam | File "/opt/venv/lib/python3.11/site-packages/apscheduler/executors/base.py", line 125, in run_job ibeam | retval = job.func(job.args, job.kwargs) ibeam | File "/srv/ibeam/src/gateway_client.py", line 159, in _maintenance ibeam | success, shutdown, status = self.start_and_authenticate(request_retries=var.REQUEST_RETRIES) ibeam | File "/srv/ibeam/src/gateway_client.py", line 128, in start_and_authenticate ibeam | success, shutdown, status = self.strategy_handler.try_authenticating(request_retries=request_retries) ibeam | File "/srv/ibeam/src/strategy_handler.py", line 84, in try_authenticating ibeam | return self._authentication_strategy_B(status, request_retries) ibeam | File "/srv/ibeam/src/strategy_handler.py", line 139, in _authentication_strategy_B ibeam | return self._log_in(status) ibeam | File "/srv/ibeam/src/strategy_handler.py", line 150, in _log_in ibeam | success, shutdown = self.log_in_function() ibeam | File "/srv/ibeam/src/gateway_client.py", line 106, in _log_in ibeam | return log_in(driver_path=self.driver_path, ibeam | File "/srv/ibeam/src/authenticate.py", line 312, in log_in ibeam | trigger = WebDriverWait(driver, var.OAUTH_TIMEOUT).until( ibeam | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ibeam | File "/opt/venv/lib/python3.11/site-packages/selenium/webdriver/support/wait.py", line 95, in until ibeam | raise TimeoutException(message, screen, stacktrace) ibeam | ibeam | <class 'selenium.common.exceptions.TimeoutException'> Message: ibeam | ibeam | 2023-06-29 16:32:00,901|I| Cleaning up the resources. Display: <pyvirtualdisplay.display.Display object at 0x7f1975f99710> | Driver: <selenium.webdriver.chrome.webdriver.WebDriver (session="70896739a2191be3955fe9fb4ae1a233")> ibeam | 2023-06-29 16:32:00,951|I| Logging in failed ibeam | 2023-06-29 16:32:29,395|I| Maintenance
Sadly, it looks like I'll have to abandon strategy B for now because it appears to be stuck in a loop.
ibeam | 2023-06-29 16:44:46,842|I| Webpage displayed "Client login succeeds" ibeam | 2023-06-29 16:44:48,843|I| Cleaning up the resources. Display: <pyvirtualdisplay.display.Display object at 0x7f1975f88450> | Driver: <selenium.webdriver.chrome.webdriver.WebDriver (session="d4baa27f202d25a12cdc1d975996231f")> ibeam | 2023-06-29 16:44:48,889|I| Logging in succeeded ibeam | 2023-06-29 16:44:50,019|I| Repeating status check attempts another 14 times ibeam | 2023-06-29 16:45:05,283|I| Max status check retries reached after 15 attempts. Consider increasing the retries by setting IBEAM_MAX_STATUS_CHECK_ATTEMPTS environment variable ibeam | 2023-06-29 16:45:05,283|I| NOT CONNECTED Status(running=True, session=True, connected=False, authenticated=False, competing=False, collision=False, session_id='e85dcbb1fb41a4a61684937149618ae3', server_name=None, server_version=None, expires=581698)
@Voyz From my side, it has been running the whole day today, and I didn't observe any issues. I will leave it for the next few days and let you know if something goes wrong.
@Voyz 👏 Strategy B worked well in my server last week, good job! 🥳
Let's observe it for more weeks.
@migoohao Mine is going into a authentication loop for strategy B in our Debian GNU/Linux 11 (bullseye) Server. Can you please help with your server setup ?
@Voyz 0.5 Strategy B version throws error (attached in the log below) during maintenance. Is this an expected behaviour ? Thanks
2023-07-11 09:08:16,411|I| Gateway running and authenticated, session id: c1567fc89b630802a333c9d207c887fb, server name: JifH16040
2023-07-11 09:09:15,779|I| Maintenance
2023-07-11 09:09:16,413|I| Gateway running and authenticated, session id: c1567fc89b630802a333c9d207c887fb, server name: JifH16040
2023-07-11 09:10:15,779|I| Maintenance
2023-07-11 09:10:16,437|I| Gateway running and authenticated, session id: c1567fc89b630802a333c9d207c887fb, server name: JifH16040
2023-07-11 09:11:15,779|I| Maintenance
2023-07-11 09:11:16,408|I| Gateway running and authenticated, session id: c1567fc89b630802a333c9d207c887fb, server name: JifH16040
2023-07-11 09:12:15,779|I| Maintenance
2023-07-11 09:12:16,563|I| Gateway running and authenticated, session id: c1567fc89b630802a333c9d207c887fb, server name: JifH16040
2023-07-11 09:13:15,779|I| Maintenance
2023-07-11 09:13:30,807|E| Connection timeout after 15 seconds. Consider increasing timeout by setting IBEAM_REQUEST_TIMEOUT environment variable. Error: The read operation timed out
2023-07-11 09:13:30,807|I| Attempt number 2
2023-07-11 09:13:31,053|E| Unrecognised HTTPError
Traceback (most recent call last):
File "/srv/ibeam/src/http_handler.py", line 119, in _request
response = self.url_request(url, method=method)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/srv/ibeam/src/http_handler.py", line 104, in url_request
return urllib.request.urlopen(req, context=self.ssl_context, timeout=self.request_timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/urllib/request.py", line 216, in urlopen
return opener.open(url, data, timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/urllib/request.py", line 525, in open
response = meth(req, response)
^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/urllib/request.py", line 634, in http_response
response = self.parent.error(
^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/urllib/request.py", line 563, in error
return self._call_chain(*args)
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/urllib/request.py", line 496, in _call_chain
result = func(*args)
^^^^^^^^^^^
File "/usr/local/lib/python3.11/urllib/request.py", line 643, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 503: Service Unavailable
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/srv/ibeam/src/http_handler.py", line 139, in _request
raise RuntimeError('Unrecognised HTTPError') from e
RuntimeError: Unrecognised HTTPError
2023-07-11 09:13:31,058|I| Max request retries reached after 2 attempts. Consider increasing the retries by setting IBEAM_REQUEST_RETRIES environment variable
2023-07-11 09:13:31,058|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)
2023-07-11 09:13:31,058|I| Authentication strategy: "B"
2023-07-11 09:13:31,058|I| No active sessions, logging in...
2023-07-11 09:13:31,058|I| Loading auth webpage at https://localhost:5000/sso/Login?forwardTo=22&RL=1&ip2loc=on
2023-07-11 09:14:07,145|E| Timeout reached when waiting for authentication. The website seems to not be loaded correctly. Consider increasing IBEAM_PAGE_LOAD_TIMEOUT.
Website URL: https://localhost:5000/sso/Login?forwardTo=22&RL=1&ip2loc=on
IBEAM_PAGE_LOAD_TIMEOUT: 30
Exception:
File "/usr/local/lib/python3.11/threading.py", line 995, in _bootstrap
self._bootstrap_inner()
File "/usr/local/lib/python3.11/threading.py", line 1038, in _bootstrap_inner
self.run()
File "/usr/local/lib/python3.11/threading.py", line 975, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 83, in _worker
work_item.run()
File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/opt/venv/lib/python3.11/site-packages/apscheduler/executors/base.py", line 125, in run_job
retval = job.func(*job.args, **job.kwargs)
File "/srv/ibeam/src/gateway_client.py", line 159, in _maintenance
success, shutdown, status = self.start_and_authenticate(request_retries=var.REQUEST_RETRIES)
File "/srv/ibeam/src/gateway_client.py", line 128, in start_and_authenticate
success, shutdown, status = self.strategy_handler.try_authenticating(request_retries=request_retries)
File "/srv/ibeam/src/strategy_handler.py", line 84, in try_authenticating
return self._authentication_strategy_B(status, request_retries)
File "/srv/ibeam/src/strategy_handler.py", line 139, in _authentication_strategy_B
return self._log_in(status)
File "/srv/ibeam/src/strategy_handler.py", line 150, in _log_in
success, shutdown = self.log_in_function()
File "/srv/ibeam/src/gateway_client.py", line 106, in _log_in
return log_in(driver_path=self.driver_path,
File "/srv/ibeam/src/authenticate.py", line 257, in log_in
driver.get(base_url + var.ROUTE_AUTH)
File "/opt/venv/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py", line 449, in get
self.execute(Command.GET, {"url": url})
File "/opt/venv/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py", line 440, in execute
self.error_handler.check_response(response)
File "/opt/venv/lib/python3.11/site-packages/selenium/webdriver/remote/errorhandler.py", line 245, in check_response
raise exception_class(message, screen, stacktrace)
2023-07-11 15:24:16,280|I| Gateway running and authenticated, session id: c1567fc89b630802a333c9d207c887fb, server name: JifH16040
2023-07-11 15:25:15,779|I| Maintenance
2023-07-11 15:25:16,126|I| Gateway running and authenticated, session id: c1567fc89b630802a333c9d207c887fb, server name: JifH16040
2023-07-11 15:26:15,779|I| Maintenance
2023-07-11 15:26:16,597|I| Gateway running and authenticated, session id: c1567fc89b630802a333c9d207c887fb, server name: JifH16040
2023-07-11 15:27:15,779|I| Maintenance
2023-07-11 15:27:16,160|I| Gateway running and authenticated, session id: c1567fc89b630802a333c9d207c887fb, server name: JifH16040
2023-07-11 15:28:15,779|I| Maintenance
2023-07-11 15:28:16,168|I| Gateway running and authenticated, session id: c1567fc89b630802a333c9d207c887fb, server name: JifH16040
2023-07-11 15:29:15,779|I| Maintenance
2023-07-11 15:29:16,234|I| Gateway running and authenticated, session id: c1567fc89b630802a333c9d207c887fb, server name: JifH16040
2023-07-11 15:30:15,779|I| Maintenance
2023-07-11 15:30:16,166|I| Gateway running and authenticated, session id: c1567fc89b630802a333c9d207c887fb, server name: JifH16040
2023-07-11 15:31:15,779|I| Maintenance
2023-07-11 15:31:16,655|I| Gateway running and authenticated, session id: c1567fc89b630802a333c9d207c887fb, server name: JifH16040
2023-07-11 15:32:15,779|I| Maintenance
2023-07-11 15:32:16,242|E| Unrecognised HTTPError
Traceback (most recent call last):
File "/srv/ibeam/src/http_handler.py", line 119, in _request
response = self.url_request(url, method=method)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/srv/ibeam/src/http_handler.py", line 104, in url_request
return urllib.request.urlopen(req, context=self.ssl_context, timeout=self.request_timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/urllib/request.py", line 216, in urlopen
return opener.open(url, data, timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/urllib/request.py", line 525, in open
response = meth(req, response)
^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/urllib/request.py", line 634, in http_response
response = self.parent.error(
^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/urllib/request.py", line 563, in error
return self._call_chain(*args)
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/urllib/request.py", line 496, in _call_chain
result = func(*args)
^^^^^^^^^^^
File "/usr/local/lib/python3.11/urllib/request.py", line 643, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 503: Service Unavailable
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/srv/ibeam/src/http_handler.py", line 139, in _request
raise RuntimeError('Unrecognised HTTPError') from e
RuntimeError: Unrecognised HTTPError
2023-07-11 15:32:16,244|I| Attempt number 2
2023-07-11 15:32:17,128|I| Gateway running and authenticated, session id: c1567fc89b630802a333c9d207c887fb, server name: JifH16040
2023-07-11 15:33:15,779|I| Maintenance
2023-07-11 15:33:16,221|I| Gateway running and authenticated, session id: c1567fc89b630802a333c9d207c887fb, server name: JifH16040
2023-07-11 15:34:15,779|I| Maintenance
2023-07-11 15:34:16,118|I| Gateway running and authenticated, session id: c1567fc89b630802a333c9d207c887fb, server name: JifH16040
2023-07-11 15:35:15,779|I| Maintenance
2023-07-11 15:35:16,614|I| Gateway running and authenticated, session id: c1567fc89b630802a333c9d207c887fb, server name: JifH16040
2023-07-11 15:36:15,779|I| Maintenance
2023-07-11 15:36:16,138|I| Gateway running and authenticated, session id: c1567fc89b630802a333c9d207c887fb, server name: JifH16040
2023-07-11 15:37:15,779|I| Maintenance
2023-07-11 15:37:16,254|I| Gateway running and authenticated, session id: c1567fc89b630802a333c9d207c887fb, server name: JifH16040
2023-07-11 15:38:15,779|I| Maintenance
2023-07-11 15:38:16,237|I| Gateway running and authenticated, session id: c1567fc89b630802a333c9d207c887fb, server name: JifH16040
2023-07-11 15:39:15,779|I| Maintenance
2023-07-11 15:39:16,679|I| Gateway running and authenticated, session id: c1567fc89b630802a333c9d207c887fb, server name: JifH16040
2023-07-11 15:40:15,779|I| Maintenance
2023-07-11 15:40:16,466|I| Gateway running and authenticated, session id: c1567fc89b630802a333c9d207c887fb, server name: JifH16040
2023-07-11 15:41:15,779|I| Maintenance
2023-07-11 15:41:16,303|I| Gateway running and authenticated, session id: c1567fc89b630802a333c9d207c887fb, server name: JifH16040
2023-07-11 15:42:15,779|I| Maintenance
2023-07-11 15:42:16,155|I| Gateway running and authenticated, session id: c1567fc89b630802a333c9d207c887fb, server name: JifH16040
2023-07-11 15:43:15,779|I| Maintenance
2023-07-11 15:43:16,148|I| Gateway running and authenticated, session id: c1567fc89b630802a333c9d207c887fb, server name: JifH16040
2023-07-11 15:44:15,779|I| Maintenance
2023-07-11 15:44:16,876|I| Gateway running and authenticated, session id: c1567fc89b630802a333c9d207c887fb, server name: JifH16040
2023-07-11 15:45:15,779|I| Maintenance
2023-07-11 15:45:16,623|I| Gateway running and authenticated, session id: c1567fc89b630802a333c9d207c887fb, server name: JifH16040
2023-07-11 15:46:15,779|I| Maintenance
2023-07-11 15:46:16,111|I| Gateway running and authenticated, session id: c1567fc89b630802a333c9d207c887fb, server name: JifH16040
2023-07-11 15:47:15,779|I| Maintenance
2023-07-11 15:47:16,773|I| Gateway running and authenticated, session id: c1567fc89b630802a333c9d207c887fb, server name: JifH16040
2023-07-11 15:48:15,779|I| Maintenance
2023-07-11 15:48:16,108|I| Gateway running and authenticated, session id: c1567fc89b630802a333c9d207c887fb, server name: JifH16040
2023-07-11 15:49:15,779|I| Maintenance
2023-07-11 15:49:16,610|I| Gateway running and authenticated, session id: c1567fc89b630802a333c9d207c887fb, server name: JifH16040
2023-07-11 15:50:15,779|I| Maintenance
2023-07-11 15:50:16,585|I| Gateway running and authenticated, session id: c1567fc89b630802a333c9d207c887fb, server name: JifH16040
2023-07-11 15:51:15,779|I| Maintenance
2023-07-11 15:51:16,147|I| Gateway running and authenticated, session id: c1567fc89b630802a333c9d207c887fb, server name: JifH16040
2023-07-11 15:52:15,779|I| Maintenance
2023-07-11 15:52:16,170|I| Gateway running and authenticated, session id: c1567fc89b630802a333c9d207c887fb, server name: JifH16040
2023-07-11 15:53:15,779|I| Maintenance
2023-07-11 15:53:16,363|I| Gateway running and authenticated, session id: c1567fc89b630802a333c9d207c887fb, server name: JifH16040
2023-07-11 15:54:15,779|I| Maintenance
2023-07-11 15:54:16,268|I| Gateway running and authenticated, session id: c1567fc89b630802a333c9d207c887fb, server name: JifH16040
2023-07-11 15:55:15,779|I| Maintenance
2023-07-11 15:55:16,203|I| Gateway running and authenticated, session id: c1567fc89b630802a333c9d207c887fb, server name: JifH16040
2023-07-11 15:56:15,779|I| Maintenance
2023-07-11 15:56:16,142|I| Gateway running and authenticated, session id: c1567fc89b630802a333c9d207c887fb, server name: JifH16040
2023-07-11 15:57:15,779|I| Maintenance
2023-07-11 15:57:16,186|I| Gateway running and authenticated, session id: c1567fc89b630802a333c9d207c887fb, server name: JifH16040
2023-07-11 15:58:15,779|I| Maintenance
2023-07-11 15:58:16,644|I| Gateway running and authenticated, session id: c1567fc89b630802a333c9d207c887fb, server name: JifH16040
2023-07-11 15:59:15,779|I| Maintenance
2023-07-11 15:59:16,612|I| Gateway running and authenticated, session id: c1567fc89b630802a333c9d207c887fb, server name: JifH16040
2023-07-11 16:00:15,779|I| Maintenance
2023-07-11 16:00:16,890|E| IBKR server error: "HTTP Error 500: Internal Server Error". One of reasons for this error is IBKR server restart.
2023-07-11 16:00:16,891|I| Attempt number 2
2023-07-11 16:00:17,993|E| IBKR server error: "HTTP Error 500: Internal Server Error". One of reasons for this error is IBKR server restart.
2023-07-11 16:00:17,994|I| Max request retries reached after 2 attempts. Consider increasing the retries by setting IBEAM_REQUEST_RETRIES environment variable
2023-07-11 16:00:17,994|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)
2023-07-11 16:00:17,995|I| Authentication strategy: "B"
2023-07-11 16:00:17,995|I| No active sessions, logging in...
2023-07-11 16:00:17,995|I| Loading auth webpage at https://localhost:5000/sso/Login?forwardTo=22&RL=1&ip2loc=on
2023-07-11 16:00:30,845|I| Gateway auth webpage loaded
2023-07-11 16:00:30,846|I| Login attempt number 1
2023-07-11 16:00:36,178|I| Submitting the form
2023-07-11 16:00:39,755|I| Webpage displayed "Client login succeeds"
2023-07-11 16:00:41,756|I| Cleaning up the resources. Display:
@vlpraveen thanks for these logs. I believe the issues you're seeing are caused by IBKR server restarts. The 503 and 500 errors seem to indicate that. If you think these could have a different cause, I'd suggest you create a support ticket with IBKR and speak to them about this.
Regarding the authentication loop, please see: https://github.com/Voyz/ibeam/issues/152#issuecomment-1636123686
Hey friends, I've found time to do a proper revamp and handle the remaining tasks on my roadmap. This involved:
ibeam_starter.py
and then everything is passed as arguments[TYPE]@@[IDENTIFIER]
format, eg.: CSS_SELECTOR@@.btn.btn-lg.btn-primary
for the primary submit button. I concluded that such system is necessary when I realised that the 2FA forms have a very different layout for different users. Now it can be customised even more.Breaking changes:
[TYPE]@@[IDENTIFIER]
. This will most likely mean you'll need to add [TYPE]@@
to your existing env vars that specify custom DOM elements if you had any.I'm pretty happy with the results. Most recent version voyz/ibeam:0.5.0-rc3
is out, give it a shot when you've got a minute.
Strategy B with 0.5.0-rc3 worked on the first try! 🎉
ibeam | 2023-07-16 00:45:31,558|I| Gateway running and authenticated, session id: 96696cdfb672bb6a8617777c6eb6f27e, server name: JifN16024
I have tried 0.5.0-rc3 and it works perfectly. Thanks! It should be the main strategy. With the default strategy from the stable version I had issues that 70% of the time I have being disconnected and reauthenticated.
This thread helped me a lot! I am running the 0.5.0-rc4
, with auth strategy B and everything runs smoothly. Plus, a quick thank you for creating ibeam
. Simplified a lot of things for me!
IBKR/Gateway runs into returning a 503 Service Unavailable error while placing the order: /iserver/account/{accountId}/orders
All other API endpoints work without any errors or issues. Facing the error only for Order API
Did anyone else face this issue ?
@vlpraveen there's been a separate issue for 503 Service Unavailable: https://github.com/Voyz/ibeam/issues/38. Also, it is being mentioned in other issues too. Seeing that this is only one endpoint, I'd address this with IBKR
Hey guys, 0.5.0
just got released as the latest
🥳 I decided to set strategy B as the default, as there seems to be good indication that it performs better than A.
You can see full release notes here: https://github.com/Voyz/ibeam/releases/tag/v0.5.0
Big thanks to you for helping test this version out and reporting back 👏👏👏
Hey @Voyz et al. I've been trying to understand how to execute the login flow successfully and stumbled over this issue in search for answers to some of the unexpected behaviour I'm seeing. Would you say the following maps to your understanding & implementation of a successful login flow?
@Voyz I had wanted to share that I'm occasionally seeing 503 when POSTing WhatIf orders. Your analysis in the previous issue thread was spot on and a simple log into my paper trading account to raise the compete flag works to get my automation out of its death spiral of failed message processing.
I've set a monitor to let me know if my message processing is failing from 503s so it's something that I'm catching but I do think that there's some issue on IB's side with user sessions that seems to be causing the gateway to start failing with order placing.
I'm using the latest Docker image in Azure containers. I have seen strategy 'B' in my logs so I assume I've ended up using that.
@rbjorklin thanks for submitting your findings 👏 I'd suggest you start a different issue where we could discuss this
@demansou
Your analysis in the previous issue thread was spot on and a simple log into my paper trading account to raise the compete flag works to get my automation out of its death spiral of failed message processing.
Hold up hold up! Thanks for the credit, but I don't remember mentioning this and this is a great idea. Does doing so get you out of the authentication loop?
Do I understand your solution correctly:
compete
flag on.Could you comment more on this?
@demansou could you please elaborate when you find a minute?
Yes sorry I've been on vacation.
@demansou ahh gotcha you're referring to 503 not the auth loop. I just gave it a shot and indeed it seemed to have helped. I'll try it on the reauth loop too, let's see if it works. Thanks for sharing! 👏👏
Update: That also fixes timeout errors. Amazing! I'm gonna test it out on the authentication loop the next time I spot it. Fingers crossed 🤞
This issue is tracking the development of IBeam v0.5.0.
You can test the v0.5.0 by pulling the most recent
-rc*
tag, eg:voyz/ibeam:0.5.0-rc1
. Go to IBeam's Docker Hub and check what the most recent v0.5.0 tag is.Major changes:
IBEAM_AUTHENTICATION_STRATEGY
env var asA
orB
. It is possible that this is a temporary feature that will be removed once a clear winning strategy is found.reauthenticate
more than on full re-login. Many thanks for suggesting this logic flow @migoohao 👏 I also want to give kudos to any other users who mentioned usingreauthenticate
in the past.New strategy 'B' logic:
See https://github.com/Voyz/ibeam/blob/v0.5.0/ibeam/src/strategy_handler.py and look for
try_authenticating
and_authentication_strategy_B
Context:
Strategy 'B', just like strategy 'A', is run on every maintenance.
Note that the result of this logic can take one of the four forms:
✅ all good - the Gateway is running and authenticated 🔐 need auth - the Gateway is running but we need to authenticate ⚠️ something's wrong - there's been some issue so we stop this authentication attempt and wait until next maintenance 🚨 shutdown - there has been a critical error during login, so we shut IBeam down
The different authentication actions that can be taken are:
The logic is described below:
(this is subject to change)
tickle
endpoint that refreshes the session and provides us with a bunch of information on the Gateway, the current session and our authentication status. Note that Status now contains additional information (see source).authenticated
andnot competing
: ✅ all goodnot running
: ⚠️ something's wrong - we can't communicate with the Gateway, so we won't attempt authentication.Above steps are the exact same for strategy 'A' and strategy 'B'. The following is where strategy 'B' differs:
not session
: 🔐 need auth - there is a running Gateway but it has no active session, so we login using the web formnot connected
orcompeting
: 🔐 need auth - this is an indication of a conflicting session (eg. TWS or Web Portal) taking over the credentials. We logout, and then reauthenticate.Irrespectively of which of the three cases take place, we end up with carrying out the post authentication double-checks:
IBEAM_MAX_STATUS_CHECK_RETRIES
times (15 by default) b) If all Status checks finish and don't report successful authentication, call reauthenticate once again. c) Repeat this whole process up toIBEAM_MAX_REAUTHENTICATE_RETRIES
times (3 by default)not running
ornot session
ornot connected
orcompeting
ornot authenticated
:⚠️ something's wrong - the Gateway is having some issues and we aren't going to keep on trying. We'll kill its process. It will be restarted on next maintenance, hoping this will solve the issues.If you want to test this version:
IBEAM_AUTHENTICATION_STRATEGY
toB
in order to test the new strategyMinor changes:
There has been some tidying up of the
gateway_client.py
file:strategy_handler
http_handler
process_utils
secrets_handler
And minor fixes:
Status
class and handling of Gateway/authentication statussession_id
andserver_name
Roadmap:
authenticate.py
file and rework that logic there. It has grown from a small function into some nasty rotten spaghetti code and also deserves some love.~