Websocket Disconnects When Injecting

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

Yes, I see it clearly

1 Like

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

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

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.
Then we will be able to see how you have configured them.

[{"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"}]

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

[
    {
        "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"
    }
]```

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?

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

it shows nothing..

That is not a recommended version 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?

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