# WebSocket w/ Python API Not Opening/Streaming?

**URL:** <https://forum.alpaca.markets/t/websocket-w-python-api-not-opening-streaming/1932>\
**Category:** Alpaca Market Data\
**Created:** [June 30, 2020, 6:39pm UTC](https://forum.alpaca.markets/t/websocket-w-python-api-not-opening-streaming/1932 "2020-06-30T18:39:17Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![theakxis](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/theakxis/32/71_2.png) [@theakxis](https://forum.alpaca.markets/u/theakxis)\
**Post date:** [June 30, 2020, 6:39pm UTC](https://forum.alpaca.markets/t/websocket-w-python-api-not-opening-streaming/1932/1 "2020-06-30T18:39:17Z")

</div>

I’m using the code available from a tutorial at [https://github.com/hackingthemarkets/alpaca-market-data-streaming-api](https://github.com/hackingthemarkets/alpaca-market-data-streaming-api) but I can only see that the connection was closed and I can’t see that it was ever opened or that anything was streamed. Using the command line with direct json works for me but it doesn’t work for me with Python for some reason. Anyone have any guesses why? For context, when I run the exact code with my API keys in the config file, I only see the “closed connection” statement printed and nothing else happens.

---

<div class="post-metadata">

**Author:** ![X\_Hilbe](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/x_hilbe/32/1229_2.png) [@X\_Hilbe](https://forum.alpaca.markets/u/X_Hilbe)\
**Post date:** [September 2, 2020, 4:25am UTC](https://forum.alpaca.markets/t/websocket-w-python-api-not-opening-streaming/1932/2 "2020-09-02T04:25:34Z")

</div>

Same problem. Can someone please help?

---

<div class="post-metadata">

**Author:** ![Shlomik](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/shlomik/32/793_2.png) [@Shlomik](https://forum.alpaca.markets/u/Shlomik)\
**Post date:** [September 2, 2020, 12:05pm UTC](https://forum.alpaca.markets/t/websocket-w-python-api-not-opening-streaming/1932/3 "2020-09-02T12:05:12Z")

</div>

Hi, try using this example: [https://github.com/alpacahq/alpaca-trade-api-python/blob/add\_simple\_stream\_example/examples/websocket\_example.py](https://github.com/alpacahq/alpaca-trade-api-python/blob/add_simple_stream_example/examples/websocket_example.py)

---

<div class="post-metadata">

**Author:** ![X\_Hilbe](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/x_hilbe/32/1229_2.png) [@X\_Hilbe](https://forum.alpaca.markets/u/X_Hilbe)\
**Post date:** [September 2, 2020, 1:37pm UTC](https://forum.alpaca.markets/t/websocket-w-python-api-not-opening-streaming/1932/4 "2020-09-02T13:37:03Z")

</div>

Thanks for responding @Shlomik ! But after I ran the code, my computer kept displaying, “error while consuming ws messages: [SSL: CERTIFICATE\_VERIFY\_FAILED] certificate verify failed: unable to get local issuer certificate (\_ssl.c:1123).” Do you know how to fix this?

---

<div class="post-metadata">

**Author:** ![Shlomik](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/shlomik/32/793_2.png) [@Shlomik](https://forum.alpaca.markets/u/Shlomik)\
**Post date:** [September 3, 2020, 6:44am UTC](https://forum.alpaca.markets/t/websocket-w-python-api-not-opening-streaming/1932/5 "2020-09-03T06:44:19Z")

</div>

Hi, seems like something wrong with you certificate configurations. don’t think it’s related to the code you used.  
if you are using mac os I’ve seen some issues about that on stackoverflow. you should search there.

---

<div class="post-metadata">

**Author:** ![Vincent\_Chan](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/vincent_chan/32/810_2.png) [@Vincent\_Chan](https://forum.alpaca.markets/u/Vincent_Chan)\
**Post date:** [October 1, 2020, 5:38pm UTC](https://forum.alpaca.markets/t/websocket-w-python-api-not-opening-streaming/1932/6 "2020-10-01T17:38:27Z")

</div>

I tired one of the program for live quote. I need to use my live Key rather than paper Key. and then it works for me

---

<div class="post-metadata">

**Author:** ![Kubilay\_Orman](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/kubilay_orman/32/4208_2.png) [@Kubilay\_Orman](https://forum.alpaca.markets/u/Kubilay_Orman)\
**Post date:** [May 11, 2022, 7:27pm UTC](https://forum.alpaca.markets/t/websocket-w-python-api-not-opening-streaming/1932/7 "2022-05-11T19:27:09Z")

</div>

same issue for me, i treid another websocket url - the url providedb by the websocket-client docs on pip website, and with that url, the same code worked. the socket opens. however with the alpaca url - nothing happens - however it works fine through the terminal with wscat …

any ideas anyone?
