# Websocket Disconnects When Injecting

**URL:** https://discourse.nodered.org/t/websocket-disconnects-when-injecting/42798
**Category:** General
**Created:** [18 March 2021 08:36 UTC](https://discourse.nodered.org/t/websocket-disconnects-when-injecting/42798 "2021-03-18T08:36:20Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![ivexy24](https://avatars.discourse-cdn.com/v4/letter/i/df705f/32.png) [@ivexy24](https://discourse.nodered.org/u/ivexy24)
#### Post date: [18 March 2021 08:36 UTC](https://discourse.nodered.org/t/websocket-disconnects-when-injecting/42798/1 "2021-03-18T08:36:20Z")

</div>

Does anyone know why does my websocket disconnect everytime i inject a message.

---

<div class="post-metadata">

### Author: ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)
#### Post date: [18 March 2021 09:37 UTC](https://discourse.nodered.org/t/websocket-disconnects-when-injecting/42798/2 "2021-03-18T09:37:30Z")

</div>

Yes, I see it clearly

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [18 March 2021 11:01 UTC](https://discourse.nodered.org/t/websocket-disconnects-when-injecting/42798/3 "2021-03-18T11:01:42Z")

</div>

> [@ivexy24](#):
>
> Does anyone know why does my websocket disconnect

How can anyone know what is wrong unless you give a _lot_ more information?

---

<div class="post-metadata">

### Author: ![ivexy24](https://avatars.discourse-cdn.com/v4/letter/i/df705f/32.png) [@ivexy24](https://discourse.nodered.org/u/ivexy24)
#### Post date: [18 March 2021 11:46 UTC](https://discourse.nodered.org/t/websocket-disconnects-when-injecting/42798/4 "2021-03-18T11:46:24Z")

</div>

I have a server that im trying to reach out to with websocket node.I have a inject node that is going in websocket out(connect to), and websocket in node that ins connected with debug node.  
Under the websocket node i get text that says connected  
And everytime i try to inject the msg it disconnects

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [18 March 2021 12:01 UTC](https://discourse.nodered.org/t/websocket-disconnects-when-injecting/42798/5 "2021-03-18T12:01:59Z")

</div>

Select those four nodes and Export to Clipboard. (Ctrl+E or via menus). Then paste the flow here using the technique described in this post - [How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506).  
Then we will be able to see how you have configured them.

---

<div class="post-metadata">

### Author: ![ivexy24](https://avatars.discourse-cdn.com/v4/letter/i/df705f/32.png) [@ivexy24](https://discourse.nodered.org/u/ivexy24)
#### Post date: [18 March 2021 12:07 UTC](https://discourse.nodered.org/t/websocket-disconnects-when-injecting/42798/6 "2021-03-18T12:07:28Z")

</div>

[{"id":"5fe717c8.e30b68","type":"debug","z":"2bf64bee.803cc4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1250,"y":1700,"wires":},{"id":"93379af6.20fb58","type":"websocket in","z":"2bf64bee.803cc4","name":"","server":"1c783539.8cbcfb","client":"","x":850,"y":1700,"wires":[["5fe717c8.e30b68"]]},{"id":"159fbed5.3e5f41","type":"websocket out","z":"2bf64bee.803cc4","name":"","server":"","client":"2b3d73a0.959a3c","x":1140,"y":1520,"wires":},{"id":"c5a516af.6c1558","type":"inject","z":"2bf64bee.803cc4","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"SUBSCRIBE com.alephone.modbus.datapoint#ZHT0062\_1.System.LeadPump.Selection WebEvent/1.0 ","payloadType":"str","x":730,"y":1520,"wires":[["159fbed5.3e5f41"]]},{"id":"1c783539.8cbcfb","type":"websocket-listener","path":"ws://192.168.1.41:22080/webevent","wholemsg":"false"},{"id":"2b3d73a0.959a3c","type":"websocket-client","path":"ws://192.168.1.41:22080/webevent/","tls":"","wholemsg":"false"}]

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [18 March 2021 13:40 UTC](https://discourse.nodered.org/t/websocket-disconnects-when-injecting/42798/7 "2021-03-18T13:40:49Z")

</div>

You have not followed the instructions in the link I posted.

---

<div class="post-metadata">

### Author: ![ivexy24](https://avatars.discourse-cdn.com/v4/letter/i/df705f/32.png) [@ivexy24](https://discourse.nodered.org/u/ivexy24)
#### Post date: [18 March 2021 14:04 UTC](https://discourse.nodered.org/t/websocket-disconnects-when-injecting/42798/8 "2021-03-18T14:04:26Z")

</div>

````auto
[
    {
        "id": "cbd0cecb.dacfd",
        "type": "debug",
        "z": "2feacd9b.ac6522",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 770,
        "y": 780,
        "wires": []
    },
    {
        "id": "8ae8f2e4.22942",
        "type": "websocket in",
        "z": "2feacd9b.ac6522",
        "name": "",
        "server": "fb40ab8c.2074c8",
        "client": "",
        "x": 290,
        "y": 780,
        "wires": [
            [
                "cbd0cecb.dacfd"
            ]
        ]
    },
    {
        "id": "9f6c89bd.09bdc8",
        "type": "websocket out",
        "z": "2feacd9b.ac6522",
        "name": "",
        "server": "",
        "client": "416da4de.9734dc",
        "x": 780,
        "y": 640,
        "wires": []
    },
    {
        "id": "14c70c0e.6a9264",
        "type": "inject",
        "z": "2feacd9b.ac6522",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "{\"name\":\"ZHT0062_1.System.LeadPump.Selection\"}",
        "payloadType": "json",
        "x": 290,
        "y": 640,
        "wires": [
            [
                "9f6c89bd.09bdc8"
            ]
        ]
    },
    {
        "id": "fb40ab8c.2074c8",
        "type": "websocket-listener",
        "path": "ws://192.168.1.41:22080/webevent",
        "wholemsg": "false"
    },
    {
        "id": "416da4de.9734dc",
        "type": "websocket-client",
        "path": "ws://192.168.1.41:22080/webevent",
        "tls": "",
        "wholemsg": "false"
    }
]```
````

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [18 March 2021 14:17 UTC](https://discourse.nodered.org/t/websocket-disconnects-when-injecting/42798/9 "2021-03-18T14:17:22Z")

</div>

What OS/hardware are you running node red on?

What version of node-red?

What version of node.js?

What does the server log show when it disconnects?

---

<div class="post-metadata">

### Author: ![ivexy24](https://avatars.discourse-cdn.com/v4/letter/i/df705f/32.png) [@ivexy24](https://discourse.nodered.org/u/ivexy24)
#### Post date: [18 March 2021 14:20 UTC](https://discourse.nodered.org/t/websocket-disconnects-when-injecting/42798/10 "2021-03-18T14:20:27Z")

</div>

win10  
node.js v15.2.1  
node-red v1.2.9

it shows nothing..

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [18 March 2021 15:31 UTC](https://discourse.nodered.org/t/websocket-disconnects-when-injecting/42798/11 "2021-03-18T15:31:32Z")

</div>

> [@ivexy24](#):
>
> node.js v15.2.1

That is not a [recommended version](https://nodered.org/docs/faq/node-versions) of node.js. It may not be the cause of the problem but I suggest that you go back to 14.x in order to check.  
After downgrading you will need to re-install node-red and go into your .node-red folder and run  
`npm install rebuild`

If that doesn't help then can you increase the log level on the server?

---

<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: [17 May 2021 15:31 UTC](https://discourse.nodered.org/t/websocket-disconnects-when-injecting/42798/12 "2021-05-17T15:31:46Z")

</div>

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