Open woolf100 opened 1 year ago
more and more connections are opened using always new ports with only one of them causing network traffic.
What connections are you talking about?
he always on display strategy using an I-Pad with Safari to display the basicUI sitemap
Is it something specific to Safari? Do you show the same issue with Chrome or Firefox on your PC for example?
What connections are you talking about?:
Client Server
Openhabserver:PortA Camera:PortX
Openhabserver:PortB Camera:PortX
Openhabserver:PortC Camera:PortX
....
Ipad:PortR Openhabserver:8080
Ipad:PortV Openhabserver:8080
Ipad:PortW Openhabserver:8080
....
the raspberry sends about 90Gigabytes a day with a single 640*480 mjpeg stream camera this way, I took a closer look and found multiple parallel streams of about the same datarate to be active today so they seem to be not all unused but some even transmit in parallel.
I have not tried using only a PC as a client till now
Please show the code of your sitemap page containing all your video elements. Maybe something due to the usage of visibility attribute?
Could you check with only one video element without visibility attribute?
I would not be surprised that a video stream is started even for your hidden widgets.
How many video elements do you have on your page?
If you properly set the encoding attribute, normally the visibility is correctly considered when you open the page. https://github.com/openhab/openhab-webui/blob/main/bundles/org.openhab.ui.basic/src/main/java/org/openhab/ui/basic/internal/render/VideoRenderer.java#L76
And if the visibility changes while the page is already opened, this should be property handled in JavaScript code too. But maybe this code is not working in Safari?
So several questions for you:
I try to answer all the above questions in one post:
I am not an expert but If I read the code you linked correctly each time the visibility is set to "On" the url is pulled and a new connection to render the video is started. If visibility switches to "off" the url is removed but I do not see that the video connection which is currently playing is closed? Am I missing something?
The issue happens with one, two three and four streams so for analysis assuming a single camera with the code in the first post is sufficient
Streams were tested from different sources tested so far:
Sitemap is as it was desigend in notepad++ sometime starting in openhab 2.4.x
I will test using Safari with only one stream not hidden overnigth and come back with the result, depending on the outcome next step would then be firefox with the same stream but hiding and unhiding or is there anything else that would be of more help to find the issue?
Looking at the code why is the MJPEG stream proxied but the HLS is not? is there a possibility to override the MJPEG proxying to test if that solves the issue?
Update:
Runing without visibility works somehow OK using Safari
For testing purposes I installed The Openhab app for IOs and had it run there with three streams tagged by a visibility flag activated and deactivated fom time to time. After 57 hours I ended up having about 20 parallel streams into the Openhab system and outwards to theTablet having sent ~700Gigabytes and received a total of ~700Gigabyte within 57 hours. I cannot prove hoewver which rendering engin is used by the Openhab App. Would it be of interest to also test this with firefox or any other distinct browser?
Runing without visibility works somehow OK using Safari
Ok so it is a problem with hidden widget streaming the video.
For testing purposes I installed The Openhab app for IOs and had it run there with three streams tagged by a visibility flag activated and deactivated fom time to time. After 57 hours I ended up having about 20 parallel streams into the Openhab system
Would mean that video streams are not stopped when hidden.
Would it be of interest to also test this with firefox or any other distinct browser?
Yes please, if you can. I would be a little surprised that noone discovered that if it affects all WEB browsers. In the meanwhile, I will check in the (JavaScript) code if I see something strange.
Firefox on an IOS Tablet results in the same issue as Safari and the Openhab app. I will try to setup a test on an android tablet in the next days.
Can you please propose an example of sitemap that shows the problem and that I can reuse for my own tests? How do you monitor the number of opened streams?
To start I would suggest something like this:
sitemap test label="test" { Frame label="A" { Switch item=WasserzirkulationOsramOnOff_Toggle label="Strom Türklingel" icon="wallswitch" visibility=[WasserzirkulationOsramOnOff_Toggle==OFF] valuecolor=[OFF="red"] Video url="http://zoneminderIP/zm/cgi-bin/nph-zms?mode=jpeg&monitor=2&scale=100" encoding="mjpeg" visibility=[Kamera==ON] Video url="http://zoneminderIP/zm/cgi-bin/nph-zms?mode=jpeg&monitor=1&scale=100" encoding="mjpeg" visibility=[Kamera==ON] Text item=DoorStatus valuecolor=[OPEN="red"] Switch item=DoorbellMute valuecolor=[ON="red"] visibility=[DoorbellMute==ON] Text item=WindowStatus valuecolor=[OPEN="red", OPEN_DG="red", OPEN_EG="red", OPEN_EG_DG="red", OPEN_DG_UG="red", OPEN_EG_UG="red", OPEN_EG_DG_UG="red"] {Group item=gWindows} Text item=GarageDoor valuecolor=[OPEN="red"] visibility=[GarageDoor==OPEN] Switch item=Garage_control label="Position [%.0f %%]" icon="garagedoor" valuecolor=[0="red"] Switch item=WaterAlert visibility=[WaterAlert==ON] Switch item=FireAlert visibility=[FireAlert==ON] mappings=[OFF="OK", ON="FIRE"] } }
Open streams are monitored with calling
sudo tcptrack -i wlan0
and simply counting streams with data flow from and to the IPaddesses
additionally I use teh data from the network binding as I can typically see a dramatic increas in download/upload total amount once the issue has started. As I wrote above worst case were about 700 Gigabytes in under 60 hours.
This may be a browser bug. https://bugs.chromium.org/p/chromium/issues/detail?id=73395 When the widget is hidden, we replace the img src by the source of the "none" icon. I was expecting that the previous source to be stopped and destroyed. Apparently for Chrome, setting the source to "" would stop the video. But the message is old.
interesting, I currently ran a separate test streaming directly to a second window not through openhab proxy four streams in parallel without hiding to see if that would also cause strange behaviour which it did not for almost a week now. I found something interesting in my network config which migth have made it worse. If dhcp is set in /etc/network then apparently this overrides dhcpd settings not only for the element it is set but for all network cards mentioned below its first call at least at some timepoint throughout startup. This led to one interface having two IP adresses one showing up using "ip route" and the other showing up in ifconfig. Openhab somehow knew both of them in its management gui. I could imagine that the faulty hiding and unhiding described in your post might have caused the system to call new streams through the same physical network card but using different IPs leading to the network stalls observed, but this is just speculation for now. I will run a test the next days to check if at least the total blocking vanishes with only one IP per network card.
What is doing the JavaScript code is just to update the src attribute of the HTML img tag, switching between your video URL and a static none icon. The video URL is in fact a proxied URL delivered by the OH server.
I did some more tests, The issue can be forced by opening multiple streams (I use 5 for testing now 640*360 pixels mjpeg) put them in one subelement e.g. Text item=Kamera label="Kameras" icon="camera"{ }
and when you enter this it works fine, however when I use the backbutton something goes wrong and it takes long to leave this page or in some cases I cannot leave at all. after doing thate few times I have numeros streams still existing and streaming even when back on the first basicui screen where no such elements are located at all. The streams vanish if I close the browser.
Which UI are you reporting an issue for?
The problem
Since I upgraded To OH 3.4.1 (coming from 2.5.12) Streaming MJPEG data causes an interesting Problem. Inserting even multiple Videos in the sitemap using code like this was never a problem with OH 2.5 Video label="vidstream" icon="video" url="XXX" encoding="mjpeg" visibility=[Object==ON] they would dynamically appear and disappear based on the item state of "Object" With OH3.4.1 this still works in general but after a while will crash my network stack on all installations I tested. Using "tcptrack -i wlan0" shows that more and more connections are opened using always new ports with only one of them causing network traffic. However the old connections seem to remain open and occupy ports. After a while it appears as if all ports available are occupied and wlan0 becomes unreachable. ## Your suggestionLet the browser stream the video and don't route it through openhab, or alternatively ensure that unused ports are closed or maybe cleaned up afer a while.
Your environment
Reproducibility and Enironments tested: Operating Systems: Debian Buster and Bullseye
Devices The Issue can be reproduced on the following Systems: Raspberry 4 8GB Openhabian Image Raspberry 4 8GB Manual installation Raspberry Pi3B+ Openhabian Image Raspberry Pi3B+ Manual installation Rock PI 4 2gb manual OH installation (not tried anything else)
The client info below is misleading as it was copied from a PC environment and does not represent the always on display strategy using an I-Pad with Safari to display the basicUI sitemap
one of the setups:
Additional information