# Missing socketID impacts dashboard template

**URL:** https://discourse.nodered.org/t/missing-socketid-impacts-dashboard-template/43634
**Category:** Dashboard
**Created:** [4 April 2021 09:23 UTC](https://discourse.nodered.org/t/missing-socketid-impacts-dashboard-template/43634 "2021-04-04T09:23:52Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)
#### Post date: [4 April 2021 09:23 UTC](https://discourse.nodered.org/t/missing-socketid-impacts-dashboard-template/43634/1 "2021-04-04T09:23:53Z")

</div>

Working in a dashboard that has a tab that will be visualized in two (or three) different monitors at the same time (queue control in an hospital sector). I simplified and changed the flow to the minimum size that reproduces the issue.

Buttons 1 and 2 do the same thing in a slightly different way. In order to understand the issue you need to open the dashboard in two separate Chrome browsers (can be in the same computer).

 ![A-1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/7/e70a15027214d95e7e987598fc208de4c9ba115f.jpeg)

When button 1 is clicked the patient name will be displayed in the green announcement area in both computers. This is just perfect.

Now, press button 2 and the patient name will show up in only one computer. This is bad.

This is the flow.

 ![A-4](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/f/df6d6a2e648274d55080bd22f04359139e0d1df7.jpeg)

```auto
[{"id":"ea4a462.c6c5eb8","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"4adcd77.55b5428","type":"ui_template","z":"ea4a462.c6c5eb8","group":"e82460d6.00eef","name":"Announcement","order":3,"width":"8","height":"4","format":"<style>\n\n#Painel_Video .nr-dashboard-template {\n background : rgb(16,203,97);\n text-align: center;\n}\n\n</style>\n\n\n<div id=\"tex1\" class=\"sizedText\"></div>\n\n<script>\n\n(function(scope) {\n scope.$watch('msg', function(msg) {\n if (msg) {\n console.log(msg);\n var x = document.getElementById('tex1');\n x.textContent = msg.patient; \n }\n });\n})(scope);\n\n</script>","storeOutMessages":false,"fwdInMessages":false,"resendOnRefresh":false,"templateScope":"local","x":860,"y":160,"wires":[[]]},{"id":"48d8231.17e56dc","type":"ui_button","z":"ea4a462.c6c5eb8","name":"","group":"e82460d6.00eef","order":1,"width":"4","height":"1","passthru":true,"label":"Call Patient 1","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","topicType":"str","x":290,"y":160,"wires":[["e2a883c5.238f2"]]},{"id":"e2a883c5.238f2","type":"function","z":"ea4a462.c6c5eb8","name":"node.send","func":"node.send({\"id\" : \"1234\"});","outputs":1,"noerr":0,"initialize":"","finalize":"","x":470,"y":160,"wires":[["8a4c5f7b.318b"]]},{"id":"8a4c5f7b.318b","type":"function","z":"ea4a462.c6c5eb8","name":"","func":"msg.patient = \"AIOT\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":660,"y":160,"wires":[["4adcd77.55b5428","7257a752.e6cef8"]]},{"id":"7257a752.e6cef8","type":"debug","z":"ea4a462.c6c5eb8","name":"MSG 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":810,"y":100,"wires":[]},{"id":"614100d7.a982c","type":"ui_button","z":"ea4a462.c6c5eb8","name":"","group":"e82460d6.00eef","order":2,"width":"4","height":"1","passthru":true,"label":"Call Patient 2","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","topicType":"str","x":290,"y":220,"wires":[["449f4bb5.0abca4"]]},{"id":"449f4bb5.0abca4","type":"function","z":"ea4a462.c6c5eb8","name":"standard msg passing","func":"msg.id = \"5678\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":500,"y":220,"wires":[["f6b95ba6.d74b18"]]},{"id":"f6b95ba6.d74b18","type":"function","z":"ea4a462.c6c5eb8","name":"","func":"msg.patient = \"MAKER\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":680,"y":220,"wires":[["4adcd77.55b5428","829a5db7.b9495"]]},{"id":"829a5db7.b9495","type":"debug","z":"ea4a462.c6c5eb8","name":"MSG 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":810,"y":260,"wires":[]},{"id":"e82460d6.00eef","type":"ui_group","name":"Video","tab":"8507c867.0a7328","order":8,"disp":false,"width":"16","collapse":false},{"id":"8507c867.0a7328","type":"ui_tab","name":"Painel","icon":"fa-television","order":1,"disabled":false,"hidden":false}]

```

Of course I could use only the function node that works as I expect but the point is that I want to understand why this is happening. It bothers me the fact that the "troubled" part of the flow uses the standard way of passing messages in Node-RED.

After more than six hours of troubleshooting I was able to identify that there is a small but crucial difference related to the way of passing messages. The most usual way generates a socketID number whereas using the `send` method will not generate the socketID number.

 ![A-2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/2/0213c51f699950f7c1275fe286a0e4f6e043e0e2.jpeg)

![A-3](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/1/0115bc0f1e84bd0f687500415efca471446219bc.jpeg)

I did a search in the forum to find that a similar issue was reported in the past.

> [@Dashboard Socket ID bug?](https://discourse.nodered.org/t/dashboard-socket-id-bug/6229/2):
>
> Hey @hugobox, I haven't much time, but you can debug the code in the [ui.js](https://github.com/node-red/node-red-dashboard/blob/master/ui.js#L268) file if you want to see it with your own eyes. In that code snippet, all messages arrive from your dashboard. However when you start in the dashboard with your own constructed message, there will be less original information available as explained below... In line 269 another function is being called to do some processing before sending the message on the output of your Button node: For button A the origin…

I am lost as I was not expecting that the code inside the ui template node could behave in a different way because of lack of socketID. My understanding is that the runtime would send messages to the all connected template nodes regardless of socketID number.

I am not sure if this is indeed a bug or it is my understanding of the working of ui template node (with scope.$watch) that need to be revised.

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [4 April 2021 12:04 UTC](https://discourse.nodered.org/t/missing-socketid-impacts-dashboard-template/43634/2 "2021-04-04T12:04:35Z")

</div>

It's not template node specific - it is the way the whole dashboard works... Only messages arriving from a UI widget will contain a valid socketid. The dashboard will then (if the socketid is intact) then only reply back to that socketid - precisely so you can do things like only set an alert/notification popup back to that socket (otherwise everyone has to hit OK/Cancel which gets very annoying) - or you can use it to send a ui\_control back to only one socket so they can switch tabs without switching all screens.

So if the socketid exists the msg gets sent to that socketid - if not (ie has been either deleted deliberately or a new message generated eg via node.send) then the msg is sent to all.

So yes - working as designed.

---

<div class="post-metadata">

### Author: ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)
#### Post date: [4 April 2021 13:30 UTC](https://discourse.nodered.org/t/missing-socketid-impacts-dashboard-template/43634/3 "2021-04-04T13:30:21Z")

</div>

Hi @dceejay , indeed makes sense. Thank you very much !!!

---

<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: [18 April 2021 13:30 UTC](https://discourse.nodered.org/t/missing-socketid-impacts-dashboard-template/43634/4 "2021-04-18T13:30:33Z")

</div>

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