# Pass message between websocket-in and websocket-out

**URL:** https://discourse.nodered.org/t/pass-message-between-websocket-in-and-websocket-out/63133
**Category:** General
**Created:** [27 May 2022 08:23 UTC](https://discourse.nodered.org/t/pass-message-between-websocket-in-and-websocket-out/63133 "2022-05-27T08:23:05Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Tiramisupxl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tiramisupxl/32/61647_2.png) [@Tiramisupxl](https://discourse.nodered.org/u/Tiramisupxl)
#### Post date: [27 May 2022 08:23 UTC](https://discourse.nodered.org/t/pass-message-between-websocket-in-and-websocket-out/63133/1 "2022-05-27T08:23:06Z")

</div>

How to pass message between websocket-in and websocket-out node? I have set a msg.device before websocket-in node and want to get it after websocket-out node, but I got undefined.  
I cannot use flow variables to save it, because it will be overwrited if I execute the same flow many times at the same time

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [27 May 2022 08:51 UTC](https://discourse.nodered.org/t/pass-message-between-websocket-in-and-websocket-out/63133/2 "2022-05-27T08:51:40Z")

</div>

> [@Tiramisupxl](#):
>
> How to pass message between websocket-in and websocket-out node

There is a built in demo (`CTRL-I` --\> examples --\> node-red --\> network)

Here is the websocket example adjusted to send/recieve entire message...

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/8/d8de058d84e192b42713392c0c83e564d19c3aab.png)

Demo Flow (use `CTRL-I` to import)

```auto
[{"id":"13410716.69c9d9","type":"websocket in","z":"d5aee383de79fdc8","name":"","server":"89db22b6.9aa36","client":"","x":1680,"y":240,"wires":[["c2541f10.59544"]]},{"id":"c2541f10.59544","type":"debug","z":"d5aee383de79fdc8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1830,"y":240,"wires":[]},{"id":"6788839e.04576c","type":"inject","z":"d5aee383de79fdc8","name":"device 123","props":[{"p":"payload"},{"p":"device","v":"123","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Hello, World!","payloadType":"str","x":1680,"y":140,"wires":[["438c232a.06c2cc"]]},{"id":"438c232a.06c2cc","type":"websocket out","z":"d5aee383de79fdc8","name":"","server":"","client":"63620788.bda128","x":1900,"y":180,"wires":[]},{"id":"bce24e49dfdf0d40","type":"inject","z":"d5aee383de79fdc8","name":"device 321","props":[{"p":"payload"},{"p":"device","v":"321","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Hello, World!","payloadType":"str","x":1680,"y":180,"wires":[["438c232a.06c2cc"]]},{"id":"89db22b6.9aa36","type":"websocket-listener","path":"/ws1","wholemsg":"true"},{"id":"63620788.bda128","type":"websocket-client","path":"ws://localhost:1880/ws1","tls":"","wholemsg":"true","hb":"0","subprotocol":""}]

```

---

<div class="post-metadata">

### Author: ![Tiramisupxl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tiramisupxl/32/61647_2.png) [@Tiramisupxl](https://discourse.nodered.org/u/Tiramisupxl)
#### Post date: [1 June 2022 01:51 UTC](https://discourse.nodered.org/t/pass-message-between-websocket-in-and-websocket-out/63133/3 "2022-06-01T01:51:08Z")

</div>

Thanks for your reply.Maybe I didn't express clearly. The websocket in and out node connect the outside server, not the server created in node-red

---

<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: [31 July 2022 01:51 UTC](https://discourse.nodered.org/t/pass-message-between-websocket-in-and-websocket-out/63133/4 "2022-07-31T01:51:45Z")

</div>

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