# WS Listen, seems to hang

**URL:** https://community.tempest.earth/t/ws-listen-seems-to-hang/11953
**Category:** Developers
**Tags:** tempest
**Created:** [January 25, 2021, 11:22pm UTC](https://community.tempest.earth/t/ws-listen-seems-to-hang/11953 "2021-01-25T23:22:22Z")
**Posts on this page:** 1
**Showing post:** 6

<div class="post-metadata">

### Author: ![peter](https://sea2.discourse-cdn.com/flex020/user_avatar/community.tempest.earth/peter/32/1365_2.png) [@peter](https://community.tempest.earth/u/peter)
#### Post date: [January 26, 2021, 8:53am UTC](https://community.tempest.earth/t/ws-listen-seems-to-hang/11953/6 "2021-01-26T08:53:32Z")

</div>

It looks like you _may_ have based your code off the snippet I shared here: [Basic Python websockets example to retrieve current Tempest data](https://community.tempest.earth/t/basic-python-websockets-example-to-retrieve-current-tempest-data/9310/). If that is the case, the code I shared was not designed to receive multiple messages from the Websocket, and the same is true in the code you shared. Once you have sent the listen command, `ws.recv()` is only called once, and therefore you will only receive a single message.

If you want to remain connected and listen to new messages continuously, you need to wrap `ws.recv()` inside a `while` loop. Something like this will work (don’t forget to enter values for the `personal_token` and `tempest_ID`):

```auto
from websocket import create_connection

personal_token = ' '
tempest_ID = ' '

print('Opening Websocket connection...')
ws = create_connection('wss://ws.weatherflow.com/swd/data?api_key=' + personal_token)
result = ws.recv()
print("Received '%s'" % result)
print('')

print('Listening to Tempest endpoint...')
ws.send('{"type":"listen_start",' + ' "device_id":' + tempest_ID + ', "id":"Tempest"}')
result = ws.recv()
print("Received '%s'" % result)
print('')

print('Receiving Tempest data...')
while True:
    result = ws.recv()
    print("Received '%s'" % result)
    print('')

```

---

_[View the full topic](https://community.tempest.earth/t/ws-listen-seems-to-hang/11953)._
