How to create a server for websocket node

image

hi shimu, u must to explain your problem better
i think u mean this

[{"id":"8a2b77d8.7c8e68","type":"http response","z":"c4fd988a.ab0db8","name":"","statusCode":"","headers":{},"x":430,"y":580,"wires":[]},{"id":"fb94312c.e079e","type":"websocket in","z":"c4fd988a.ab0db8","name":"","server":"7070206c.62f4","client":"","x":100,"y":620,"wires":[["b275a5e.3e23e58"]]},{"id":"14b00429.d65e3c","type":"http in","z":"c4fd988a.ab0db8","name":"","url":"url","method":"get","upload":false,"swaggerDoc":"","x":100,"y":580,"wires":[["dba11beb.2b5508"]]},{"id":"dba11beb.2b5508","type":"template","z":"c4fd988a.ab0db8","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<div>Web works</div>\n<script>var ws = new  WebSocket(\"ws://localhost:1881/ws/url\");\nvar message={}\n\nws.onopen = function() {\n   message = {\n    'payload': 'Client connected'\n  };\n  ws.send(JSON.stringify(message));\n};</script>","output":"str","x":280,"y":580,"wires":[["8a2b77d8.7c8e68"]]},{"id":"b275a5e.3e23e58","type":"debug","z":"c4fd988a.ab0db8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":330,"y":620,"wires":[]},{"id":"7070206c.62f4","type":"websocket-listener","z":"","path":"/ws/url","wholemsg":"false"}]

Thank you very much. It's enlightening. I want the kind of page data that node controls other ports in real time. Node Red's WebSocket is equivalent to pushing MSG, and other port pages receive the MSG pushed by WebSocket.

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