Qluxzz / avanza

A Python library for the unofficial Avanza API
https://qluxzz.github.io/avanza/
MIT License
85 stars 40 forks source link

Subscription ends with error #15

Closed highviolet closed 3 years ago

highviolet commented 3 years ago

First of all, thank you for a great package.

I have a problem with subscriptions to channels that ends with an error. It occurs after the subscription has been running for roughly three hours. An ideas on how to avoid it?

Task exception was never retrieved future: <Task finished name='Task-2' coro=<AvanzaSocket.__create_socket() done, defined at .../python3.9/site-packages/avanza/avanza_socket.py:45> exception=TypeError("'>=' not supported between instances of 'NoneType' and 'int'")> Traceback (most recent call last): File ".../python3.9/site-packages/avanza/avanza_socket.py", line 51, in __create_socket await self.__socket_message_handler() File ".../python3.9/site-packages/avanza/avanza_socket.py", line 188, in __socket_message_handler await action(message) File ".../python3.9/site-packages/avanza/avanza_socket.py", line 129, in __connect not advice or (reconnect and interval >= 0) TypeError: '>=' not supported between instances of 'NoneType' and 'int'

highviolet commented 3 years ago

Hi,

I made some investigations into this.

The lines: connect_successful = successful and ( not advice or (reconnect and interval >= 0) ) Should likely be changed to: connect_successful = successful and ( not advice or (reconnect != 'none' and interval >= 0) )

Compare with https://github.com/fhqvst/avanza/blob/ca5e9053ff33e7ab1a163a19f2f4e19395cff479/lib/index.js#L299

However, after that change, I encounter a new error. When the subscription has been running for approx. 4 hours, I now get "402 :: Unkown client".

Qluxzz commented 3 years ago

Your problem after four hours might be because of this? You can change the time at Profil -> Sajtinställningar -> Automatisk utloggning. image

Qluxzz commented 3 years ago

The lines: connect_successful = successful and ( not advice or (reconnect and interval >= 0) ) Should likely be changed to: connect_successful = successful and ( not advice or (reconnect != 'none' and interval >= 0) )

Yeah, that sure seems like it. I will create a fix for it.

Thanks for investigating the issue!