# Sending rtsp camera streaming over internet

**URL:** <https://discourse.nodered.org/t/sending-rtsp-camera-streaming-over-internet/46606>\
**Category:** General\
**Created:** [2 June 2021 15:40 UTC](https://discourse.nodered.org/t/sending-rtsp-camera-streaming-over-internet/46606 "2021-06-02T15:40:07Z")\
**Posts on this page:** 1\
**Showing post:** 30

<div class="post-metadata">

**Author:** ![Lupin\_III](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lupin_iii/32/67650_2.png) [@Lupin\_III](https://discourse.nodered.org/u/Lupin_III)\
**Post date:** [5 June 2021 08:14 UTC](https://discourse.nodered.org/t/sending-rtsp-camera-streaming-over-internet/46606/30 "2021-06-05T08:14:22Z")

</div>

Thanks [krambriw](https://discourse.nodered.org/u/krambriw), I was thinking to something similar to that, with a counter increasing/decreasing by messages sent from client side via mqtt. So I could start sending the video flow when the first client is connected, and stop it when the last one is disconnected. I already implemented something similar but using ui\_control (all in local environment or even remotely but directly reaching the dashboard via IP, without remote mqtt, ecc). In that case it was easy to overcome the problem when you have a line disconnection, thanks to ui\_control. In this case, wia mqtt, I'm thinking how to face this without complicate it too much

```auto
[{"id":"8a857234.e024","type":"ui_ui_control","z":"f68e9dd6.332eb","name":"","events":"all","x":100,"y":120,"wires":[["8ec1bf4d.4f579"]]},{"id":"8ec1bf4d.4f579","type":"function","z":"f68e9dd6.332eb","name":"Connection","func":"var Connected = context.get(\"Connected\");\nvar Connection = context.get(\"Connection\");\nif (msg.payload == \"connect\"){\n Connected = true;\n Connection = Connection +1;\n}\nif (msg.payload == \"lost\"){\n Connection = Connection -1;\n if (Connection == 0){\n Connected = false;\n }\n}\n\nif (context.get(\"Connected\")==false && Connection==1){\n msg.connected = true;\n} else if (context.get(\"Connected\")==true && Connection==0){\n msg.connected = false;\n} else {\n msg.connected = null;\n}\n\ncontext.set(\"Connection\", Connection);\ncontext.set(\"Connected\", Connected);\n\nreturn [msg];","outputs":1,"noerr":0,"initialize":"// Connected\nif (context.get(\"Connected\") == undefined) {\n context.set(\"Connected\",false)\n} else {\n context.set(\"Connected\",context.get(\"Connected\"));\n}\n// Connection\nif (context.get(\"Connection\") == undefined) {\n context.set(\"Connection\",0)\n} else {\n context.set(\"Connection\",context.get(\"Connection\"));\n}\n","finalize":"","x":290,"y":120,"wires":[["93ed8d47.82bc6"]]},{"id":"93ed8d47.82bc6","type":"switch","z":"f68e9dd6.332eb","name":"","property":"connected","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":490,"y":120,"wires":[["a10f874f.074bc8","e32c83cb.58612"],["2e184129.c194fe","d6769b7e.c043d8","74f23c32.730d04"]]},{"id":"a10f874f.074bc8","type":"link out","z":"f68e9dd6.332eb","name":"Start connection","links":["92d2f636.22b858","cb32c510.a6ffe8","4f5d2049.fe3ab","c5bb114.b19caf"],"x":655,"y":80,"wires":[]},{"id":"d6769b7e.c043d8","type":"link out","z":"f68e9dd6.332eb","name":"Stop conection - Video","links":["87da0239.7b80a"],"x":655,"y":140,"wires":[]}]

```

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

---

_[View the full topic](https://discourse.nodered.org/t/sending-rtsp-camera-streaming-over-internet/46606)._
