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

[Bug]: Websocket create_connection invalid extra_headers param #531

Closed
1 task done
sanurielf opened this issue Nov 27, 2024 · 2 comments
Closed
1 task done

[Bug]: Websocket create_connection invalid extra_headers param #531

sanurielf opened this issue Nov 27, 2024 · 2 comments

Comments

@sanurielf
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

While reproducing the API-doc example:

from alpaca.data.live import StockDataStream


wss_client = StockDataStream('api-key', 'secret-key')

# async handler
async def quote_data_handler(data):
    # quote data will arrive here
    print(data)

wss_client.subscribe_quotes(quote_data_handler, "SPY")

wss_client.run()

The following appears:

TypeError: BaseEventLoop.create_connection() got an unexpected keyword argument 'extra_headers'
error during websocket communication: BaseEventLoop.create_connection() got an unexpected keyword argument 'extra_headers'

Expected Behavior

No response

SDK Version I encountered this issue in

alpaca-py version: 0.33.0
websockets version: 14.1

Steps To Reproduce

Run the following example:


from alpaca.data.live import StockDataStream


wss_client = StockDataStream('api-key', 'secret-key')

# async handler
async def quote_data_handler(data):
    # quote data will arrive here
    print(data)

wss_client.subscribe_quotes(quote_data_handler, "SPY")

wss_client.run()


### Filled out the Steps to Reproduce section?

- [X] I have entered valid steps to reproduce my issue or have attached a minimally reproducible case in code that shows my issue happening; and understand that without this my issue will be flagged as invalid and closed after 30 days.

### Anything else?

Latest websockets versions https://github.com/python-websockets/websockets/pull/1332 do not handle extra_headers, instead additional_headers is the expected parameter:


https://github.com/python-websockets/websockets/blob/59d4dcf779fe7d2b0302083b072d8b03adce2f61/src/websockets/asyncio/client.py#L278C1-L279C1




This issue must be related to this closed issue https://github.com/alpacahq/alpaca-py/issues/527
@sanurielf
Copy link
Author

@hiohiohio we either pin the websockets version (to version < 13) or update alpaca-py codes and restrict websockets >= 13. I can do the fix, please let me know what you think.

@sanurielf
Copy link
Author

Just found you already fixed in #528. Closing now.

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

1 participant