Skip to content
This repository was archived by the owner on Oct 13, 2023. It is now read-only.
This repository was archived by the owner on Oct 13, 2023. It is now read-only.

Version 0.0.6.x topic #21

@slazarov

Description

@slazarov

I haven't been active for the past 2/3 weeks so leaving a note here to highlight how reconnection will be implemented in v0.0.6.

The experimental implementation will work in the following way:

  • a watchdog thread will monitor subscriptions and check if their respective connections are active.
  • if the connection is inactive, the watchdog will send an unsubscribe method followed by subscribe method
  • a connection is marked as inactive upon exception in def _init_connection(self, conn_obj)

This implementation works on the base that connections are established independently of subscriptions. When an exception is reached in def _init_connection(self, conn_obj), the script will try to reconnect with the extra URL. If this fails, the thread that holds the connection will die. However, since the watchdog is in a separate thread, it will detect that the connection is inactive and will try to establish a new one and the whole thing begins again.

As always, I am open to recommendations.

[Update] 22/Jan/18
Due to changes in the how the code is organised as of 0.0.6.x you might get an error message when you declare a variable in on_open and then try to access it immediately. E.g:

Traceback (most recent call last):
File "python-bittrex-websocket/bittrex_websocket/examples/ticker_updates.py", line 49, in
2018-01-22 07:49:39 - bittrex_websocket.websocket_client - INFO - [Connection][da64c763df6e411c9663004a1baefec6]:Trying to establish connection to Bittrex through https://socket-stage.bittrex.com/signalr.
main()
File "python-bittrex-websocket/bittrex_websocket/examples/ticker_updates.py", line 41, in main
while len(ws.ticker_updates_container) < len(tickers):
AttributeError: 'MySocket' object has no attribute 'ticker_updates_container'

Quick workaround before I fix it is to introduce some delay after subscribing but before your logic, e.g time.sleep(5).

[Update] 21/Jan/18
Version 0.0.6.2

  • Every 5400s (1hr30) the script will force reconnection.
  • Every reconnection (including the above) will be done with a fresh cookie
  • Upon reconnection the script will check if the connection has been running for more than 600s (10mins). If it has been running for less it will use the backup url.

The timeouts (5400 and 10) are not final and are subject to results.

[Update] 14/Jan/18
I've been experimenting for the past few days and I have found that Bittrex has an embedded auto-reconnection. Meaning that if the connection drops and is reconnected through the same session either through cfscrape or requests, the invokes persist at a server level and sync with the client. Thought I have to note that I haven't tried to unsubscribe an invoke and apply a different session to it.

Anyways 0.0.6 is getting closer and thanks for the wait!

Stan

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions