# Stream Websocket Error

**URL:** <https://forum.alpaca.markets/t/stream-websocket-error/12076>\
**Category:** Alpaca Trading\
**Created:** [March 29, 2023, 5:49pm UTC](https://forum.alpaca.markets/t/stream-websocket-error/12076 "2023-03-29T17:49:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![suraj](https://avatars.discourse-cdn.com/v4/letter/s/ecccb3/32.png) [@suraj](https://forum.alpaca.markets/u/suraj)\
**Post date:** [March 29, 2023, 5:49pm UTC](https://forum.alpaca.markets/t/stream-websocket-error/12076/1 "2023-03-29T17:49:16Z")

</div>

I am trying to receive minute websocket bars via the Alpaca Stream function. My code is failing with the following error:

error during websocket communication: auth failed  
Traceback (most recent call last):  
File “/opt/anaconda3/lib/python3.9/site-packages/alpaca\_trade\_api/stream.py”, line 251, in \_run\_forever  
await self.\_start\_ws()  
File “/opt/anaconda3/lib/python3.9/site-packages/alpaca\_trade\_api/stream.py”, line 105, in \_start\_ws  
await self.\_auth()  
File “/opt/anaconda3/lib/python3.9/site-packages/alpaca\_trade\_api/stream.py”, line 99, in \_auth  
raise ValueError(msg[0].get(‘msg’, ‘auth failed’))  
ValueError: auth failed

Below is the code I used to run the websocket. Could someone assist in pinpointing the issue here? Seems like the authentication is failing.

```
async def update_bar_data(self, bar): 
    #update parameters for symbol
    print(bar)

#MAIN FUNC FOR PRICE UPDATE AND ORDER EXECUTION
async def main(self,):
    self.define_parameters()
    conn = Stream(API_KEY, API_SECRET, base_url = URL(BASE_URL), data_feed = 'sip')
    for sym in symbols:
        conn.subscribe_bars(self.update_bar_data, sym)
    await conn._run_forever()

```

---

<div class="post-metadata">

**Author:** ![Isaac\_I9](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/isaac_i9/32/5584_2.png) [@Isaac\_I9](https://forum.alpaca.markets/u/Isaac_I9)\
**Post date:** [October 17, 2023, 1:51am UTC](https://forum.alpaca.markets/t/stream-websocket-error/12076/2 "2023-10-17T01:51:19Z")

</div>

If you are using Jupyter Notebook, you probably are stuck in the event loop. Try restarting the notebook or executing it in a raw Python file.
