# Websocket crashes node-red

**URL:** <https://discourse.nodered.org/t/websocket-crashes-node-red/53880>\
**Category:** General\
**Created:** [17 November 2021 13:50 UTC](https://discourse.nodered.org/t/websocket-crashes-node-red/53880 "2021-11-17T13:50:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![davec1001](https://avatars.discourse-cdn.com/v4/letter/d/f08c70/32.png) [@davec1001](https://discourse.nodered.org/u/davec1001)\
**Post date:** [17 November 2021 13:50 UTC](https://discourse.nodered.org/t/websocket-crashes-node-red/53880/1 "2021-11-17T13:50:22Z")

</div>

I have a websocket connected to a sky box, when the sky box disconnects (ie I switch it off). it crashes node-red. I have a hearbeat set Disabling the hearbeat stops the error/crash. Should this be a bug? ie shouldn't it error more gracefully?  
Node-red Version 2.1.3

Here is the log.

```auto
17 Nov 13:23:13 - [red] Uncaught Exception:
17 Nov 13:23:13 - [error] Error: WebSocket is not open: readyState 0 (CONNECTING)

at WebSocket.ping (/usr/src/node-red/node_modules/ws/lib/websocket.js:275:13)
at Timeout._onTimeout (/usr/src/node-red/node_modules/@node-red/nodes/core/network/22-websocket.js:118:32)
at listOnTimeout (internal/timers.js:557:17)
at processTimers (internal/timers.js:500:7)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-red-docker@2.1.3 start: `node $NODE_OPTIONS node_modules/node-red/red.js $FLOWS "--userDir" "/data"`
npm ERR! Exit status 1

npm ERR! Failed at the node-red-docker@2.1.3 start script.

```

And the flow

```auto
[{"id":"483143fe0fdf9889","type":"websocket in","z":"337ab9fcb061d1af","name":"","server":"","client":"8fef0e85b64534eb","x":370,"y":460,"wires":[["03e1d48e7eb0ca5b"]]},{"id":"03e1d48e7eb0ca5b","type":"json","z":"337ab9fcb061d1af","name":"","property":"payload","action":"","pretty":false,"x":670,"y":460,"wires":[["9adf4e94a29f48cd"]]},{"id":"9adf4e94a29f48cd","type":"debug","z":"337ab9fcb061d1af","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":830,"y":460,"wires":[]},{"id":"8fef0e85b64534eb","type":"websocket-client","path":"ws://192.168.1.244:9006/as/system/status","tls":"","wholemsg":"false","hb":"10"}]

```

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [17 November 2021 14:05 UTC](https://discourse.nodered.org/t/websocket-crashes-node-red/53880/2 "2021-11-17T14:05:29Z")

</div>

Yes, this should be handled better. Having built-in support for websocket pings is a relatively new feature - it would appear there's a timing window here that has exposed some missing error handling.

Can you raise an issue on github with details? [Sign in to GitHub · GitHub](https://github.com/node-red/node-red/issues/new?assignees=&labels=needs-triage&template=bug_report.yml)

---

<div class="post-metadata">

**Author:** ![davec1001](https://avatars.discourse-cdn.com/v4/letter/d/f08c70/32.png) [@davec1001](https://discourse.nodered.org/u/davec1001)\
**Post date:** [17 November 2021 15:16 UTC](https://discourse.nodered.org/t/websocket-crashes-node-red/53880/3 "2021-11-17T15:16:42Z")

</div>

Done. Thanks

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [16 January 2022 15:17 UTC](https://discourse.nodered.org/t/websocket-crashes-node-red/53880/4 "2022-01-16T15:17:03Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
