Websocket connected and disconnected

I'm using Websocket in and out and they work fine. I need to know if a Client is connected or disconnected and whilst this is shown there is no msg available. There is an alternative node:

that provides msg.connected = true/false. However, there is a conflict shown when I try and install this.
Is there a way this can be installed please?

You may need to expand on
There is a conflict shown when I try and install this.

I select Manage Palette, Install, then search for websocket.

node-red-contrib-websocket is displayed but on the right a box that contains 'conflict' is shown. If I place my mouse on this box then "This module cannot be installed as it includes a node type that has already been installed. Conflicts with node-red" is displayed.

Have you tried using the status node it should report the connect/disconnect of the websocket nodes.

Thank you. The status node does report connect but not disconnect since the websocket does not indicate when it does not have a client connected to it unless a message is sent to the client. Then a disconnect is received after about 15 seconds.

You are mistaken , it reports connect and disconnect after timeout, no messages need to be sent.

I've left it disconnected for 10 minutes and its still showing connected. Do I need to set a timeout, if so how do I do that please?

How do you have it set up?
How are you disconnecting it?
The timeout is built into the websocket node.

It’s set up as a Websocket server. The client runs on an ESP32. All data sent to and from the client works fine and when the client first connects then I get the connect signal.
I remove the power from the ESP32 to disconnect it.

  1. What version of NR and node.js are you running? you can get this from the NR startup log (@E1cid you too)

  2. this node hasn't been updated in almost 8 years...

Latest 3.1.3 nodejs 20.2.0
@Dr_Phil export your flow please

How to import/export a flow

In order to make code readable and usable it is necessary to surround your code with three backticks (also known as a left quote or backquote ```)

``` 
   code goes here 
```

You can edit and correct your post by clicking the pencil :pencil2: icon.

See this post for more details - How to share code or flow json

I'm using Node-Red v3.1.0 and NT 10.0.19045. My code is as follows:

[
    {
        "id": "2157535e595135c6",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "83ab13540db76534",
        "type": "websocket out",
        "z": "2157535e595135c6",
        "name": "WS Server Out",
        "server": "83ae3e14c71f11ab",
        "client": "",
        "x": 540,
        "y": 340,
        "wires": []
    },
    {
        "id": "f304cc6cbb939f5c",
        "type": "websocket in",
        "z": "2157535e595135c6",
        "name": "WS Server In",
        "server": "83ae3e14c71f11ab",
        "client": "",
        "x": 250,
        "y": 460,
        "wires": [
            [
                "b2aa114626afeace"
            ]
        ]
    },
    {
        "id": "b2aa114626afeace",
        "type": "debug",
        "z": "2157535e595135c6",
        "name": "debug 2",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 500,
        "y": 460,
        "wires": []
    },
    {
        "id": "7ee01a5d1c656be8",
        "type": "comment",
        "z": "2157535e595135c6",
        "name": "WS Server /ws/test",
        "info": "",
        "x": 450,
        "y": 280,
        "wires": []
    },
    {
        "id": "3c377ddf7c022da2",
        "type": "inject",
        "z": "2157535e595135c6",
        "name": "status 1",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "{\"status\":1}",
        "payloadType": "json",
        "x": 250,
        "y": 320,
        "wires": [
            [
                "83ab13540db76534"
            ]
        ]
    },
    {
        "id": "9ea2af6953b005c5",
        "type": "inject",
        "z": "2157535e595135c6",
        "name": "status 0",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "{\"status\":0}",
        "payloadType": "json",
        "x": 250,
        "y": 380,
        "wires": [
            [
                "83ab13540db76534"
            ]
        ]
    },
    {
        "id": "7bf565bdf93cdf88",
        "type": "status",
        "z": "2157535e595135c6",
        "name": "Check Conect status",
        "scope": [
            "83ab13540db76534"
        ],
        "x": 790,
        "y": 340,
        "wires": [
            [
                "8546c3f74650a9f7"
            ]
        ]
    },
    {
        "id": "8546c3f74650a9f7",
        "type": "debug",
        "z": "2157535e595135c6",
        "name": "debug 4",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 1000,
        "y": 340,
        "wires": []
    },
    {
        "id": "8b42b490a6d66ff1",
        "type": "status",
        "z": "2157535e595135c6",
        "name": "Check Conect status",
        "scope": [
            "f304cc6cbb939f5c"
        ],
        "x": 790,
        "y": 460,
        "wires": [
            [
                "2837a776f1458c39"
            ]
        ]
    },
    {
        "id": "2837a776f1458c39",
        "type": "debug",
        "z": "2157535e595135c6",
        "name": "debug 5",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 1000,
        "y": 460,
        "wires": []
    },
    {
        "id": "83ae3e14c71f11ab",
        "type": "websocket-listener",
        "path": "/ws/test",
        "wholemsg": "false"
    }
]

Not seeing an issue in your flow,.
What is your nodejs version?

Does your esp send constant messages to the websocket in node, you could possible set up some sort of heartbeat as a workaround.

My Node.js version is v21.1.0

I'm periodically sending a ping from the ESP32 and checking I get a pong back, which if all connected I do. But this is not detected by node.red so perhaps sending heatbeat data could be used.

That is not a supported version, only LTS versions are supported. I suggest downgrading to v18 which is the current recommended version.

I've downgraded to v18 and loaded the latest node-red. Manage Palette now shows that the version of websocket installed supports msg.connected = true/false and that it is in use. It also shows 4 nodes are available:
websocket-in
websocket-out
websocket-listener
websocket-client

However, msg.connected does not provide any data, even though status node shows connected, and I can't locate all 4 nodes.

Are the nodes that you can grab from the node palette and add in your flows while

are configuration nodes that are used when you configure the other two nodes. They do not display in the flow