# Sending debug messages over a WebSocket connection

**URL:** <https://discourse.nodered.org/t/sending-debug-messages-over-a-websocket-connection/93884>\
**Category:** General\
**Tags:** debugging\
**Created:** [12 December 2024 17:07 UTC](https://discourse.nodered.org/t/sending-debug-messages-over-a-websocket-connection/93884 "2024-12-12T17:07:13Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jonathan](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Jonathan](https://discourse.nodered.org/u/Jonathan)\
**Post date:** [12 December 2024 17:07 UTC](https://discourse.nodered.org/t/sending-debug-messages-over-a-websocket-connection/93884/1 "2024-12-12T17:07:13Z")

</div>

Is it possible to somehow add debug messages manually from outside Node-RED to the Debug side panel, where debug nodes also log their messages? I was trying to do something like this.

```auto
function connectToNodeREDWebSocket() {
    console.log('Attempting to connect to Node-RED WebSocket...');
    ws = new WebSocket('ws://127.0.0.1:1880/comms');

    ws.on('open', () => {
        console.log('WebSocket connection established with Node-RED');
        const message = {
          topic: "debug",
          data: {
              msg: "Hello from WebSocket client!",
              timestamp: Date.now(),
              level: 20
          }
      };
        ws.send(JSON.stringify(message));
    });
}

```

I manage to establish a connection but Node-RED doesn't seem to display any messages in the Debug panel.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [12 December 2024 17:39 UTC](https://discourse.nodered.org/t/sending-debug-messages-over-a-websocket-connection/93884/2 "2024-12-12T17:39:52Z")

</div>

Certainly. Set up a websocket-in node as a listener. Connect to it from the browser. Anything you send over that link will appear in Node-RED as a msg so just attach a downstream debug node and you are good to go.

---

<div class="post-metadata">

**Author:** ![Jonathan](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Jonathan](https://discourse.nodered.org/u/Jonathan)\
**Post date:** [12 December 2024 18:03 UTC](https://discourse.nodered.org/t/sending-debug-messages-over-a-websocket-connection/93884/3 "2024-12-12T18:03:00Z")

</div>

Is it also possible to directly send a message to this Debug side panel? Without the use of a websocket-in node or debug node? I thought Node-RED itself also used a websocket connection internally where nodes can publish messages too for it to be displayed inside the Debug panel. I basically want a way to notify the Node-RED user without setting up any nodes beforehand. You think this is possible? For your information, i'm not building an application in Node-RED i'm building an extension of Node-RED.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [12 December 2024 18:06 UTC](https://discourse.nodered.org/t/sending-debug-messages-over-a-websocket-connection/93884/4 "2024-12-12T18:06:25Z")

</div>

There is an internal API that lets you send to debug from the runtime. But you still need a way to accept a websocket connection and call the api.

Not a native feature but you could probably create a plugin to do it.

---

<div class="post-metadata">

**Author:** ![Jonathan](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Jonathan](https://discourse.nodered.org/u/Jonathan)\
**Post date:** [13 December 2024 00:40 UTC](https://discourse.nodered.org/t/sending-debug-messages-over-a-websocket-connection/93884/5 "2024-12-13T00:40:30Z")

</div>

Oh okay, I'm not familiar with these plugins. Is there some documentation on how to create/add these plugins to Node-RED?

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [13 December 2024 01:28 UTC](https://discourse.nodered.org/t/sending-debug-messages-over-a-websocket-connection/93884/6 "2024-12-13T01:28:34Z")

</div>

The Node-RED docs have some info.

---

<div class="post-metadata">

**Author:** ![gregorius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gregorius/32/73816_2.png) [@gregorius](https://discourse.nodered.org/u/gregorius)\
**Post date:** [13 December 2024 10:29 UTC](https://discourse.nodered.org/t/sending-debug-messages-over-a-websocket-connection/93884/7 "2024-12-13T10:29:04Z")

</div>

> [@Jonathan](#):
>
> send a message to this Debug side panel?

Yes, if you want to do this in the frontend, i.e. in the editor, then this is an [implementation of the debug node](https://github.com/gorenje/cdn.flowhub.org/blob/b80d22b841d26d35983b4e810e9c233013887126/red/deadred.js#L372-L459) that runs in the frontend - the core is: `RED.comms.emit([{ "topic": "debug", "data": debugData }])`

From the server side this is a little more tricky but checkout the [debug node](https://github.com/node-red/node-red/blob/2854351909dee9f92597faba3f37239134294eec/packages/node_modules/%40node-red/nodes/core/common/21-debug.js#L227) for the answer - the core is `RED.comms.publish("debug",msg);` - `msg` isn't the object we think of it being!

Serverside example code is also [the msg debugger](https://github.com/gorenje/node-red-contrib-introspection/blob/ef97b4665e1734a55b62b587cdf069a0d857b79c/nodes/60-client-code.js#L29-L53) inside the [introspection](https://flows.nodered.org/node/@gregoriusrippenstein/node-red-contrib-introspection) package which does better describe what the `msg` object in this case looks like.

---

<div class="post-metadata">

**Author:** ![gregorius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gregorius/32/73816_2.png) [@gregorius](https://discourse.nodered.org/u/gregorius)\
**Post date:** [13 December 2024 10:34 UTC](https://discourse.nodered.org/t/sending-debug-messages-over-a-websocket-connection/93884/8 "2024-12-13T10:34:13Z")

</div>

> [@Jonathan](#):
>
> For your information, i'm not building an application in Node-RED i'm building an extension of Node-RED.

For that you want to create a endpoint inside of node red, for example, HTTP-in node that accepts connections to `/notify/node/red/user/about/something` then from outside of node-red, you send a HTTP POST to that endpoint. The http-in node is connected to a debug node and bobs your uncle.

The NodeRED flow would be something like this:

```auto
[{"id":"830ea901315f9180","type":"http in","z":"5f23149bb8dc98d4","name":"","url":"/notify/node/red/user/about/something","method":"post","upload":false,"swaggerDoc":"","x":571,"y":258,"wires":[["e169270b39512330"]]},{"id":"e169270b39512330","type":"debug","z":"5f23149bb8dc98d4","name":"debug 118","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":902,"y":259,"wires":[]}]

```

---

<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:** [13 March 2025 10:34 UTC](https://discourse.nodered.org/t/sending-debug-messages-over-a-websocket-connection/93884/9 "2025-03-13T10:34:43Z")

</div>

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