# \[FIXED\] Websocket to reply individually?

**URL:** https://discourse.nodered.org/t/fixed-websocket-to-reply-individually/42878
**Category:** General
**Created:** [19 March 2021 12:45 UTC](https://discourse.nodered.org/t/fixed-websocket-to-reply-individually/42878 "2021-03-19T12:45:55Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![j2l](https://avatars.discourse-cdn.com/v4/letter/j/ee59a6/32.png) [@j2l](https://discourse.nodered.org/u/j2l)
#### Post date: [19 March 2021 12:45 UTC](https://discourse.nodered.org/t/fixed-websocket-to-reply-individually/42878/1 "2021-03-19T12:45:56Z")

</div>

When I setup websocket to echo the input:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/c/dce3572f229a5878b49f782d6911147c247afe00.png)  
The output message is never sent to the client.  
Actually, the message is output from the function node but the exit point never delivers it.

Then I red [WebSocket Node multiple clients - #4 by knolleary](https://discourse.nodered.org/t/websocket-node-multiple-clients/29917/4) and tried a few things:

- removing msg.\_session.id broadcasts of course
- removing msg.\_session.type (i.e the string "Websocket"), and keeping msg.\_session.id, broadcasts too ...

Any idea why this behavior?  
How to send a websocket message to only the client with the msg.\_session.id?  
Thank you

---

<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: [19 March 2021 13:08 UTC](https://discourse.nodered.org/t/fixed-websocket-to-reply-individually/42878/2 "2021-03-19T13:08:53Z")

</div>

msg.\_session is required if you want to send a reply to the originator. If you remove it, all ws clients that are subscribed to your endpoint will get the message.

Two things to check:

1. Make sure that the output from your function node is what you think it is using a debug node on the output.
2. Check your client code to make sure that it is actually connected to the right endpoint. If the client is in a web page, you can use your browser dev tools to check the flow of data.

---

<div class="post-metadata">

### Author: ![j2l](https://avatars.discourse-cdn.com/v4/letter/j/ee59a6/32.png) [@j2l](https://discourse.nodered.org/u/j2l)
#### Post date: [19 March 2021 13:15 UTC](https://discourse.nodered.org/t/fixed-websocket-to-reply-individually/42878/3 "2021-03-19T13:15:24Z")

</div>

Simple echo is not working, it should since it has everything (session id, type and payload)

Everything is checked and working, except all messages are broadcasted, even with \_session.id kept:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/2/8236088c9718ca28d32367f212c6418c587abdbf.png)  
uuid here is to identify from the client side

and from the server side, we can see both uuid and session id:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/0/70890b16be4a3c47027f7b333e3609759e0254bb.png)

But everything is still broadcasted.

Please do a test (3 nodes). I use NR 1.2.9.

---

<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: [19 March 2021 13:58 UTC](https://discourse.nodered.org/t/fixed-websocket-to-reply-individually/42878/4 "2021-03-19T13:58:34Z")

</div>

Tested and it is working fine for me.

Use [WebSocket King client: A testing and debugging tool for WebSockets](https://websocketking.com/) for testing, it lets you set up multiple client connections very easily.

---

<div class="post-metadata">

### Author: ![j2l](https://avatars.discourse-cdn.com/v4/letter/j/ee59a6/32.png) [@j2l](https://discourse.nodered.org/u/j2l)
#### Post date: [19 March 2021 14:04 UTC](https://discourse.nodered.org/t/fixed-websocket-to-reply-individually/42878/5 "2021-03-19T14:04:13Z")

</div>

I can't, it's on the LAN

---

<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: [19 March 2021 14:04 UTC](https://discourse.nodered.org/t/fixed-websocket-to-reply-individually/42878/6 "2021-03-19T14:04:48Z")

</div>

So is mine. It is a web tool but, just like your own code, it sends everything from your browser.

---

<div class="post-metadata">

### Author: ![j2l](https://avatars.discourse-cdn.com/v4/letter/j/ee59a6/32.png) [@j2l](https://discourse.nodered.org/u/j2l)
#### Post date: [19 March 2021 14:17 UTC](https://discourse.nodered.org/t/fixed-websocket-to-reply-individually/42878/7 "2021-03-19T14:17:05Z")

</div>

Ah, OK, thanks.

So, injection from server and send OK.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/a/ca7e18880b736664d46f2787ab5c558c3820472b.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/2/c2bbd4b4f076f07d585a0829fe804f9fc744b229.png)  
But no echo.  
Did you try echo?  
Did you connect to both ends (entry and exit) with King client?  
Could you please show me your setup and results?

---

<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: [19 March 2021 14:24 UTC](https://discourse.nodered.org/t/fixed-websocket-to-reply-individually/42878/8 "2021-03-19T14:24:47Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/b/fbbb3d158a88a727345648141d0bb8666f44cd00.png)

Same as yours. The function does nothing but is there so I can test removal of the msg.\_session.

Normal operation:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/3/137c0e65d16e3f105fbb3d689058e005d91993b8.png)

Removal of \_session:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/7/f79a0cecceea8605ab3cfb86e035b75c0257b992.png)

---

<div class="post-metadata">

### Author: ![j2l](https://avatars.discourse-cdn.com/v4/letter/j/ee59a6/32.png) [@j2l](https://discourse.nodered.org/u/j2l)
#### Post date: [19 March 2021 14:43 UTC](https://discourse.nodered.org/t/fixed-websocket-to-reply-individually/42878/9 "2021-03-19T14:43:32Z")

</div>

OK, I understand.  
I mistakenly used 2 different endpoints (from a post about websocket chat, my bad).

---

<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: [2 April 2021 14:44 UTC](https://discourse.nodered.org/t/fixed-websocket-to-reply-individually/42878/10 "2021-04-02T14:44:17Z")

</div>

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