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

extra_headers not compatible with v14.0 #1588

Closed
Pithikos opened this issue Feb 1, 2025 · 3 comments
Closed

extra_headers not compatible with v14.0 #1588

Pithikos opened this issue Feb 1, 2025 · 3 comments

Comments

@Pithikos
Copy link

Pithikos commented Feb 1, 2025

While trying to resolve issue #1587 (comment) I run into another one when trying to upgrade from v12 to v14. (Note it works until 13.1)

Example

extra_headers = {"Authorization": f"Bearer {auth_token}"}
async with websockets.connect(uri, extra_headers=extra_headers) as ws:
    ...

It seems that extra_headers parameter doesn't work with the new release and breaks existing code.

Traceback

Traceback (most recent call last):
  File "/home/alex/workspace/projectx/controller/controller.py", line 812, in <module>
    asyncio.run(connection_loop(state))
  File "/usr/lib/python3.12/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/alex/workspace/projectx/controller/controller.py", line 723, in connection_loop
    async with websockets.connect(
  File "/home/alex/workspace/projectx/.venv/lib/python3.12/site-packages/websockets/asyncio/client.py", line 484, in __aenter__
    return await self
           ^^^^^^^^^^
  File "/home/alex/workspace/projectx/.venv/lib/python3.12/site-packages/websockets/asyncio/client.py", line 441, in __await_impl__
    self.connection = await self.create_connection()
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/alex/workspace/projectx/.venv/lib/python3.12/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'
@aaugustin
Copy link
Member

The changelog for version 14.0 has a big warning and a link to this guide.

@Pithikos
Copy link
Author

Pithikos commented Feb 1, 2025

Thanks, I just skimmed over the release notes and didn't find anything relevant. I assume this works then

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants