# Websocket issue I could use some help with

**URL:** <https://community.tempest.earth/t/websocket-issue-i-could-use-some-help-with/19048>\
**Category:** Developers\
**Created:** [November 12, 2022, 1:58am UTC](https://community.tempest.earth/t/websocket-issue-i-could-use-some-help-with/19048 "2022-11-12T01:58:47Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![chris1](https://avatars.discourse-cdn.com/v4/letter/c/ac91a4/32.png) [@chris1](https://community.tempest.earth/u/chris1)\
**Post date:** [November 12, 2022, 1:58am UTC](https://community.tempest.earth/t/websocket-issue-i-could-use-some-help-with/19048/1 "2022-11-12T01:58:47Z")

</div>

I have a javascript implementation that’s overall working fine. I open my web socket connection, start listening for obs\_st and rapid\_wind, and all is right with the world…for a while.

After approximately 24 hours the obs\_st messages stop coming - but rapid\_wind continues without issue.

In my error handling logic, I watch when it’s been too long since I’ve heard an update and do a listen\_stop, listen\_start for obs\_st messages, which elicits just a single update message and no more.

So once I end up in this state, the only updates that I get at that point forward for obs\_st is when my error handler kicks in (roughly every 7 minutes) Meanwhile, rapid-wind is unaffected and continues to come in uninterrupted.

If I close the app (killing the connection) and re-open the app it will be fine again for 24 hours.

What am I missing…? Should I just kill and re-open the connection every 24 hours pre-emptively? That just seems like voodoo, but sometimes voodoo does the trick.

Station ID 163515

---

<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:** [November 12, 2022, 7:51am UTC](https://community.tempest.earth/t/websocket-issue-i-could-use-some-help-with/19048/2 "2022-11-12T07:51:35Z")

</div>

I am having the same problem with the PiConsole. Just like you are seeing, websocket messages stop arriving for some reason. A reboot of the console can fix it, but only for some unknown period of time.

I think it is a bug in the API on the WF side that they are looking into, but I haven’t heard if they have been able to identify it (@corrineb)

---

<div class="post-metadata">

**Author:** ![chris1](https://avatars.discourse-cdn.com/v4/letter/c/ac91a4/32.png) [@chris1](https://community.tempest.earth/u/chris1)\
**Post date:** [November 12, 2022, 3:15pm UTC](https://community.tempest.earth/t/websocket-issue-i-could-use-some-help-with/19048/3 "2022-11-12T15:15:00Z")

</div>

Ah - ok - that’s kinda what I suspected. If it helps in troubleshooting, I’ve left my devices (2 clients, device id in my original post) in their error-handling state - rapid wind continues on happily, other measurements only updating when the stop/start which again only triggers a single message.

---

<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:** [November 13, 2022, 7:10am UTC](https://community.tempest.earth/t/websocket-issue-i-could-use-some-help-with/19048/4 "2022-11-13T07:10:47Z")

</div>

It happened to me again last night on my Weewx box that fetches data via the Websocket. `obs_st` packets just stopped around 20:30 GMT, while `rapid_wind` continued.

 ![Screenshot_20221113-070817](https://us1.discourse-cdn.com/flex020/uploads/sws/original/2X/4/442ffc030109194da79b05ded954082802e6c569.jpeg)

---

<div class="post-metadata">

**Author:** ![chris1](https://avatars.discourse-cdn.com/v4/letter/c/ac91a4/32.png) [@chris1](https://community.tempest.earth/u/chris1)\
**Post date:** [November 17, 2022, 3:42pm UTC](https://community.tempest.earth/t/websocket-issue-i-could-use-some-help-with/19048/5 "2022-11-17T15:42:40Z")

</div>

Seems to be resolved…multiple days and obs\_st’s are still coming in. @peter are you seeing same?

---

<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:** [November 18, 2022, 7:49pm UTC](https://community.tempest.earth/t/websocket-issue-i-could-use-some-help-with/19048/6 "2022-11-18T19:49:54Z")

</div>

It’s looking good so far. My Weewx instance has been dropping in and out for a few days, but seems a lot more stable now

---

<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:** [November 22, 2022, 9:14am UTC](https://community.tempest.earth/t/websocket-issue-i-could-use-some-help-with/19048/8 "2022-11-22T09:14:41Z")

</div>

Are you still seeing issues, or are you back up and running?

---

<div class="post-metadata">

**Author:** ![chris1](https://avatars.discourse-cdn.com/v4/letter/c/ac91a4/32.png) [@chris1](https://community.tempest.earth/u/chris1)\
**Post date:** [November 22, 2022, 3:11pm UTC](https://community.tempest.earth/t/websocket-issue-i-could-use-some-help-with/19048/9 "2022-11-22T15:11:43Z")

</div>

Hi @peter - ya, it came back.

I caught the failure in progress - my error recovery tries to fix it, and fails eventually with too many connections. I would really love if someone could look over this log and tell me where I’m going wrong? Once I go into recovery, it doesn’t seem like there’s a way to clean up and I eventually get locked out such that I have to kill the app and wait.

[wf\_console\_log.txt](https://community.tempest.earth/uploads/short-url/trcNP00BPXgWuDysDicrCmdtBnT.txt) (85.5 KB)

---

<div class="post-metadata">

**Author:** ![livysdad27](https://sea2.discourse-cdn.com/flex020/user_avatar/community.tempest.earth/livysdad27/32/14185_2.png) [@livysdad27](https://community.tempest.earth/u/livysdad27)\
**Post date:** [November 28, 2022, 5:56am UTC](https://community.tempest.earth/t/websocket-issue-i-could-use-some-help-with/19048/10 "2022-11-28T05:56:49Z")

</div>

@peter I’ve been having issues with my Weewx implementation as well. It’s compounded by a lack of power that comes and goes, I just installed a powerbooster.

Do you mind sharing what driver you’re using for Weewx?

Billy

---

<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:** [November 30, 2022, 4:31pm UTC](https://community.tempest.earth/t/websocket-issue-i-could-use-some-help-with/19048/11 "2022-11-30T16:31:08Z")

</div>

Not sure I can really help here, as I don’t know javascript. From your description, it sounds like when your code catches the failure to send messages, it doesn’t actually close the websocket connection before opening a new one. As the issue is with the messages not being sent (rather than the websocket connection failing), you need to find a way to shut the existing connection down before opening a new one.

---

<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:** [November 30, 2022, 4:31pm UTC](https://community.tempest.earth/t/websocket-issue-i-could-use-some-help-with/19048/12 "2022-11-30T16:31:56Z")

</div>

> [@livysdad27](#):
>
> Do you mind sharing what driver you’re using for Weewx?

Unfortunately, the driver I am using is not really in a shareable state. It is something I have hacked together with a lot of aspects hard-coded to my specific setup. Sorry!

---

<div class="post-metadata">

**Author:** ![livysdad27](https://sea2.discourse-cdn.com/flex020/user_avatar/community.tempest.earth/livysdad27/32/14185_2.png) [@livysdad27](https://community.tempest.earth/u/livysdad27)\
**Post date:** [November 30, 2022, 4:48pm UTC](https://community.tempest.earth/t/websocket-issue-i-could-use-some-help-with/19048/13 "2022-11-30T16:48:28Z")

</div>

Gotcha,

No worries. I pulled one together but it could use some improvements in a few areas so I’m always curious to learn more and see what I could do better. I need to improve my error handling and my reconnection code works when Weatherflow recycles the connection for some reason but in some states it doesn’t seem to be happy and doesn’t reconnect without a full restart. I have a ticket open with them on the second item.

Good luck on that front! I might build one against the REST API as well in the future.

Billy
