I haven't found a way to do this right
Would someone know how to limit receiving many api requests, sending Error 429 (too many requests) to all clients?
In this way that I have, it is only sent to the last
[{"id":"2c6e40c2.7824f","type":"http in","z":"ccdd1e82.45d92","name":"","url":"/api/ajax","method":"get","upload":false,"swaggerDoc":"","x":150,"y":2940,"wires":[["4b619d55.b302a4"]]},{"id":"de998de2.ce80a","type":"http response","z":"ccdd1e82.45d92","name":"","statusCode":"","headers":{},"x":1010,"y":2940,"wires":[]},{"id":"4b619d55.b302a4","type":"template","z":"ccdd1e82.45d92","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":" <h1>AJAX</h1>\n <button type=\"button\" onclick=\"loadDoc()\">Change Content</button>\n<div id=\"demo\">\n <h2>Let AJAX change this text</h2>\n \n</div>\n\n<script>\n \n function loadDoc() {\n var xhttp = new XMLHttpRequest();\n xhttp.onreadystatechange = function() {\n if (this.readyState == 4 && this.status == 200) {\n document.getElementById(\"demo\").innerHTML = this.responseText;\n }\n };\n xhttp.open(\"GET\", \"/api/sender\", true);\n xhttp.send();\n} \n \n</script>","output":"str","x":380,"y":2940,"wires":[["de998de2.ce80a"]]},{"id":"20fe94b7.72f73c","type":"http in","z":"ccdd1e82.45d92","name":"","url":"/api/sender","method":"get","upload":false,"swaggerDoc":"","x":160,"y":3020,"wires":[["b127bd28.b011f"]]},{"id":"f78c0abb.04f078","type":"http response","z":"ccdd1e82.45d92","name":"","statusCode":"","headers":{},"x":1010,"y":3020,"wires":[]},{"id":"f173924c.115bf","type":"template","z":"ccdd1e82.45d92","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"text","output":"str","x":800,"y":3020,"wires":[["f78c0abb.04f078","44e95b19.acd924"]]},{"id":"a1ad0bdd.8379a8","type":"delay","z":"ccdd1e82.45d92","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"5","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":560,"y":3020,"wires":[["f6e534f3.868098"]]},{"id":"5ca15075.02425","type":"status","z":"ccdd1e82.45d92","name":"","scope":["a1ad0bdd.8379a8"],"x":140,"y":3080,"wires":[["79b66316.b882ac"]]},{"id":"79b66316.b882ac","type":"change","z":"ccdd1e82.45d92","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"status","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":255,"y":3080,"wires":[["b127bd28.b011f","5015e505.793d2c"]],"l":false},{"id":"b127bd28.b011f","type":"function","z":"ccdd1e82.45d92","name":"set counter","func":"if(msg.topic == \"status\"){\n if( (!isNaN(msg.status.text)&&parseInt(msg.status.text))){\n context.set(\"count\",parseInt(msg.status.text))\n }\n else{\n context.set(\"count\",0)\n }\n}\nelse{\n if(context.get(\"count\")>5){\n msg.reset=true //resetea sin enviar nada mas que al ultimo , \n // msg.flush=true //resetea enviando los mensajes de golpe , \n node.send(msg)\n msg.statusCode=429\n node.warn(\"Error 429 Too Many Requests\")\n throw new Error(\"Error 429 Too Many Requests\")\n }\n\n return msg\n}","outputs":1,"noerr":0,"x":390,"y":3020,"wires":[["a1ad0bdd.8379a8"]]},{"id":"44e95b19.acd924","type":"debug","z":"ccdd1e82.45d92","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1010,"y":2980,"wires":[]},{"id":"a76b7f22.98978","type":"catch","z":"ccdd1e82.45d92","name":"","scope":["b127bd28.b011f"],"uncaught":false,"x":130,"y":3140,"wires":[["742bd8c3.f34078","a31a2942.323908"]]},{"id":"742bd8c3.f34078","type":"http response","z":"ccdd1e82.45d92","name":"","statusCode":"","headers":{},"x":1010,"y":3140,"wires":[]},{"id":"a31a2942.323908","type":"debug","z":"ccdd1e82.45d92","name":"ERRR","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":250,"y":3180,"wires":[]},{"id":"5015e505.793d2c","type":"debug","z":"ccdd1e82.45d92","name":"TOPIC","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":370,"y":3080,"wires":[]},{"id":"f6e534f3.868098","type":"function","z":"ccdd1e82.45d92","name":" imagine that I am a function that uses a lot of cpu","func":"\nreturn msg;","outputs":1,"noerr":0,"x":750,"y":3060,"wires":[["f173924c.115bf"]]}]
In this example, the requests would accumulate in the delay node with each click on the button.
When sending more than 5 requests, it should send error 429, but I only get this with one client.
the test I'm doing is to open 2 or 3 tabs and try clicking alternately
EDIT: this is the result i get, but i want it on both clients