Add vnc password auth, connection reset logic
Now that we have working client auth thanks to: https://github.com/barneygale/asyncvnc/pull/4 and related issue, we can use a pw for the vnc server, though we should eventually auto-generate a random one from a docker super obviously. Add logic to the data reset hack loop to do a connection reset after 2 failed/timeout attempts at the regular data reset. We need to also add this logic around reconnectionn events that are due to the host network connection: aka roaming that's faster then timing logic builtin to the gateway.ib_dedicated_data_client
parent
8d6c5b214e
commit
06832b94d4
|
@ -13,4 +13,4 @@ x11vnc \
|
||||||
-autoport 3003 \
|
-autoport 3003 \
|
||||||
# can't use this because of ``asyncvnc`` issue:
|
# can't use this because of ``asyncvnc`` issue:
|
||||||
# https://github.com/barneygale/asyncvnc/issues/1
|
# https://github.com/barneygale/asyncvnc/issues/1
|
||||||
# -passwd "$VNC_SERVER_PASSWORD"
|
-passwd 'ibcansmbz'
|
||||||
|
|
|
@ -1588,29 +1588,55 @@ async def get_bars(
|
||||||
hist_ev = proxy.status_event(
|
hist_ev = proxy.status_event(
|
||||||
'HMDS data farm connection is OK:ushmds'
|
'HMDS data farm connection is OK:ushmds'
|
||||||
)
|
)
|
||||||
# live_ev = proxy.status_event(
|
|
||||||
# # 'Market data farm connection is OK:usfuture'
|
|
||||||
# 'Market data farm connection is OK:usfarm'
|
|
||||||
# )
|
|
||||||
|
|
||||||
# port = proxy._aio_ns.ib.client.port
|
# XXX: other event messages we might want to try and
|
||||||
await data_reset_hack()
|
# wait for but i wasn't able to get any of this
|
||||||
|
# reliable..
|
||||||
|
# reconnect_start = proxy.status_event(
|
||||||
|
# 'Market data farm is connecting:usfuture'
|
||||||
|
# )
|
||||||
|
# live_ev = proxy.status_event(
|
||||||
|
# 'Market data farm connection is OK:usfuture'
|
||||||
|
# )
|
||||||
|
|
||||||
# try to wait on the reset event(s) to arrive, a timeout
|
# try to wait on the reset event(s) to arrive, a timeout
|
||||||
# will trigger a retry up to 6 times (for now).
|
# will trigger a retry up to 6 times (for now).
|
||||||
for i in range(6):
|
tries: int = 6
|
||||||
with trio.move_on_after(6) as cs:
|
reset_type: str = 'data'
|
||||||
|
resends: int = 0
|
||||||
|
|
||||||
|
for i in range(1, tries):
|
||||||
|
|
||||||
|
log.warning(f'Sending reset request {reset_type}')
|
||||||
|
await data_reset_hack(reset_type=reset_type)
|
||||||
|
reset_type = 'data'
|
||||||
|
|
||||||
|
with trio.move_on_after(3) as cs:
|
||||||
for name, ev in [
|
for name, ev in [
|
||||||
|
# TODO: not sure if waiting on other events
|
||||||
|
# is all that useful here or not. in theory
|
||||||
|
# you could wait on one of the ones above
|
||||||
|
# first to verify the reset request was
|
||||||
|
# sent?
|
||||||
('history', hist_ev),
|
('history', hist_ev),
|
||||||
# ('live', live_ev),
|
|
||||||
]:
|
]:
|
||||||
await ev.wait()
|
await ev.wait()
|
||||||
log.info(f"{name} DATA RESET")
|
log.info(f"{name} DATA RESET")
|
||||||
break
|
break
|
||||||
|
|
||||||
fails += 1
|
|
||||||
if cs.cancelled_caught:
|
if cs.cancelled_caught:
|
||||||
log.warning(f'Data reset hack failed, retrying {i}...')
|
fails += 1
|
||||||
|
log.warning(
|
||||||
|
f'Data reset {name} timeout, retrying {i}.'
|
||||||
|
)
|
||||||
|
|
||||||
|
if resends > 1:
|
||||||
|
# on each 3rd timeout, do a full connection
|
||||||
|
# reset instead.
|
||||||
|
reset_type = 'connection'
|
||||||
|
resends = 0
|
||||||
|
else:
|
||||||
|
resends += 1
|
||||||
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -2219,7 +2245,6 @@ async def trades_dialogue(
|
||||||
assert account in accounts_def
|
assert account in accounts_def
|
||||||
accounts.add(account)
|
accounts.add(account)
|
||||||
|
|
||||||
# for client in _client_cache.values():
|
|
||||||
for client in aioclients.values():
|
for client in aioclients.values():
|
||||||
for pos in client.positions():
|
for pos in client.positions():
|
||||||
|
|
||||||
|
@ -2560,8 +2585,15 @@ async def data_reset_hack(
|
||||||
async with asyncvnc.connect(
|
async with asyncvnc.connect(
|
||||||
'localhost',
|
'localhost',
|
||||||
port=5900,
|
port=5900,
|
||||||
|
password='ibcansmbz',
|
||||||
) as client:
|
) as client:
|
||||||
|
|
||||||
|
# move to middle of screen
|
||||||
|
# 640x1800
|
||||||
|
client.mouse.move(
|
||||||
|
x=100,
|
||||||
|
y=100,
|
||||||
|
)
|
||||||
client.mouse.click()
|
client.mouse.click()
|
||||||
client.keyboard.press('Ctrl', 'Alt', key) # keys are stacked
|
client.keyboard.press('Ctrl', 'Alt', key) # keys are stacked
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue