Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to download files and getting the following error in socket creation #142

Open
malinazakat opened this issue Nov 10, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@malinazakat
Copy link

malinazakat commented Nov 10, 2024

Description of the bug
I am getting the following error in multiple commands.

To Reproduce
Steps to reproduce the behavior:

  1. Ran the command pytr -v debug dl_docs 'C:\Users\XXX\Downloads'
  2. Followed the instructions

Expected behavior
Files to be downloaded.

Error log
2024-11-10 16:56:38+0100 main DEBUG logging is set to debug
2024-11-10 16:56:38+0100 account INFO Credentials file not found
Please enter your TradeRepublic phone number in the format +4912345678:
xxx
Please enter your TradeRepublic pin:
Pin (Input is hidden): xxx
Save credentials? Type "y" to save credentials:

2024-11-10 16:56:41+0100 account INFO Credentials not saved
Enter the code you received to your mobile app as a notification.
Enter nothing if you want to receive the (same) code as SMS. (Countdown: 31)
Code: xxx
2024-11-10 16:56:46+0100 account INFO Logged in
2024-11-10 16:56:46+0100 dl INFO Created history file
2024-11-10 16:56:46+0100 timeline INFO Subscribing to #1 timeline transactions
2024-11-10 16:56:46+0100 api INFO Connecting to websocket ...

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "c:\users\xxx\.local\bin\pytr.exe\__main__.py", line 7, in <module>
  File "C:\Users\xxx\pipx\venvs\pytr\Lib\site-packages\pytr\main.py", line 266, in main
    asyncio.get_event_loop().run_until_complete(dl.dl_loop())
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "C:\Users\xxx\pipx\venvs\pytr\Lib\site-packages\pytr\dl.py", line 68, in dl_loop
    await self.tl.get_next_timeline_transactions()
  File "C:\Users\xxx\pipx\venvs\pytr\Lib\site-packages\pytr\timeline.py", line 30, in get_next_timeline_transactions
    await self.tr.timeline_transactions()
  File "C:\Users\xxx\pipx\venvs\pytr\Lib\site-packages\pytr\api.py", line 506, in timeline_transactions
    return await self.subscribe({"type": "timelineTransactions", "after": after})
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\xxx\pipx\venvs\pytr\Lib\site-packages\pytr\api.py", line 322, in subscribe
    ws = await self._get_ws()
         ^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\xxx\pipx\venvs\pytr\Lib\site-packages\pytr\api.py", line 301, in _get_ws
    self._ws = await websockets.connect(
               ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\xxx\pipx\venvs\pytr\Lib\site-packages\websockets\asyncio\client.py", line 441, in __await_impl__
    self.connection = await self.create_connection()
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\xxx\pipx\venvs\pytr\Lib\site-packages\websockets\asyncio\client.py", line 367, in create_connection
    _, connection = await loop.create_connection(factory, **kwargs)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: BaseEventLoop.create_connection() got an unexpected keyword argument 'extra_headers'

Environment

  • OS: windows
  • pytr version: 0.3.1
  • Python: 3.11
@malinazakat malinazakat added the bug Something isn't working label Nov 10, 2024
@ralfescher
Copy link

I had the same error running this command on my Mac with Python 3.12.4.
Could solve this issue by running the program in a virtual python 3.9 environment (see #141).

@malinazakat
Copy link
Author

malinazakat commented Nov 10, 2024

Tried with Python 3.13 and now got slightly different error

20:19:36 Logged in
20:19:36 Created history file
20:19:36 Subscribing to #1 timeline transactions
20:19:36 Connecting to websocket ...
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "c:\users\ali\.local\bin\pytr.exe\__main__.py", line 7, in <module>
    sys.exit(main())
             ~~~~^^
  File "C:\Users\Ali\pipx\venvs\pytr\Lib\site-packages\pytr\main.py", line 266, in main
    asyncio.get_event_loop().run_until_complete(dl.dl_loop())
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
  File "C:\Users\Ali\AppData\Local\Programs\Python\Python313\Lib\asyncio\base_events.py", line 721, in run_until_complete
    return future.result()
           ~~~~~~~~~~~~~^^
  File "C:\Users\Ali\pipx\venvs\pytr\Lib\site-packages\pytr\dl.py", line 68, in dl_loop
    await self.tl.get_next_timeline_transactions()
  File "C:\Users\Ali\pipx\venvs\pytr\Lib\site-packages\pytr\timeline.py", line 30, in get_next_timeline_transactions
    await self.tr.timeline_transactions()
  File "C:\Users\Ali\pipx\venvs\pytr\Lib\site-packages\pytr\api.py", line 506, in timeline_transactions
    return await self.subscribe({"type": "timelineTransactions", "after": after})
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Ali\pipx\venvs\pytr\Lib\site-packages\pytr\api.py", line 322, in subscribe
    ws = await self._get_ws()
         ^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Ali\pipx\venvs\pytr\Lib\site-packages\pytr\api.py", line 301, in _get_ws
    self._ws = await websockets.connect(
               ^^^^^^^^^^^^^^^^^^^^^^^^^
        "wss://api.traderepublic.com", ssl=ssl_context, extra_headers=extra_headers
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "C:\Users\Ali\pipx\venvs\pytr\Lib\site-packages\websockets\asyncio\client.py", line 441, in __await_impl__
    self.connection = await self.create_connection()
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Ali\pipx\venvs\pytr\Lib\site-packages\websockets\asyncio\client.py", line 367, in create_connection
    _, connection = await loop.create_connection(factory, **kwargs)
                          ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
TypeError: BaseEventLoop.create_connection() got an unexpected keyword argument 'extra_headers'

@malinazakat
Copy link
Author

Did not work for me with Python 3.9.13 either.

@ralfescher
Copy link

I asked ChatGPT for help, and it suggested downgrading the WebSockets version:
pip install websockets==10.2
Took me also some time to get Python 3.9 running in a virtual environment (venv).

@malinazakat
Copy link
Author

Thanks a lot. worked for me too with the downgraded websockets version.

@msdn65
Copy link

msdn65 commented Nov 11, 2024

same here worked after downgrading websockets

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants