Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work around web browser connection limits #441

Closed
qoole opened this issue Jun 12, 2014 · 38 comments

Comments

@qoole
Copy link

commented Jun 12, 2014

As soon as you have 4/5 monitors in a group you can no longer view them as a montage in Google Chrome due to the fact that chrome has a hardcoded limit of 6 connections per server.

Using Cambozola is a possibility but for people, like myself, who would prefer not to have to manage Java installations/permissions/etc on the many PCs that access our CCTV system I have come up with another suggestion.

Move the 'montaging' up a level, make the stream server collate all the data from the monitors in the group into one stream and then send that down to the client rather than a stream for each individual monitor.

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@connortechnology

This comment has been minimized.

Copy link
Member

commented Jun 12, 2014

It might actually be a good idea.

@knight-of-ni

This comment has been minimized.

Copy link
Member

commented Jun 12, 2014

I'm not saying the proposed idea should not be implemented in zoneminder.
However, if this is truly a hard limit in Chrome that other browsers don't have, has anyone filed a bug report against Chrome?

@connortechnology

This comment has been minimized.

Copy link
Member

commented Jun 12, 2014

Chrome isn't the only one with a problem, firefox has it too. It's a FAQ entry. Would be better to just not have to deal with it.

@newburns

This comment has been minimized.

Copy link

commented Jun 12, 2014

Firefox has this limit, but there are writeups on how to increase this limit.
I had this issue MANY times with a Zoneminder install of 30+ monitors and multiple users. Every user setup requires additional browser configuration due to the limitation

@kylejohnson

This comment has been minimized.

Copy link
Member

commented Jun 12, 2014

We also need to consider how to solve this problem with forward-compatibility, knowing that the old web/ dir is going to go away completely at some point.

@kylejohnson

This comment has been minimized.

Copy link
Member

commented Jun 12, 2014

Personally, I think this should be fixed on the client side - in the browser. zms isn't broken. It is unreasonable to impose such a limit on us (connection limits), and depending on how the author of a given frontend implements streaming, we don't want to limit them or make them use workarounds.

@knight-of-ni

This comment has been minimized.

Copy link
Member

commented Jun 12, 2014

It's a simple, documented matter to change that in Firefox, however.

@kylejohnson

This comment has been minimized.

Copy link
Member

commented Jun 12, 2014

Agreed - I'm talking about Chrome here, really.

@qoole

This comment has been minimized.

Copy link
Author

commented Jun 12, 2014

I wholly disagree that we should expect chrome to change (or allow change of) this setting. It has been brought up many times on the Google Chrome mailing lists etc and every time they have said the setting will not be changed or exposed and if you want it to be higher then compile it yourself. If ZM makes this change and chrome do decide to change their minds in the future, what has ZM lost? You've added functionality that some frontend streaming clients might like to use

Individual streams will still be accessible, however a collated stream could also be selected.

Lots of simultaneous connections are messy and wasteful. You have a great deal of un-needed traffic in the protocol overheads.

@knight-of-ni

This comment has been minimized.

Copy link
Member

commented Jun 12, 2014

@qoole
Thank you. You did not provide that information about Crhome in your initial post, which is why I asked the question.

To answer yours, what we have lost is time spent working on other things. We have a shortage of manpower, yet we have a surplus of people suggesting what we should be spending our time on. When that happens we have to prioritize what gets done and what does not.

This does not necessarily mean we don't like the idea or don't want to implement it. What it does mean is that we are going to stay focused on other things with a higher priority. Of course, you can always roll up your sleeves and submit a pull request.

@connortechnology

This comment has been minimized.

Copy link
Member

commented Feb 3, 2015

There was a discussion from someone with an idea for a fix for this. It involved setting up multiple ports, and using a different one for each camera.

@frankc420

This comment has been minimized.

Copy link

commented Feb 28, 2015

I fixed this on my end with some elementary coding. I'll post the code below. This is my first time contributing on github so if I'm doing it in the wrong spot, please forgive me. I'm pretty sure this changes the way things are displayed on other pages as well, but that is fine for my setup.

Create X hosts pointing to your main IP. In my case, I did pixie01-15

In includes/functions.php in the getStreamSrc function (line 151 in my file), I replaced:

$streamSrc = ZM_BASE_URL.ZM_PATH_ZMS;

with:

    $_SESSION['cdnNum'] = $_SESSION['cdnNum']+1;
    if ($_SESSION['cdnNum'] == 16) $_SESSION['cdnNum'] = 1;

    $streamSrc = "//pixie".str_pad($_SESSION['cdnNum'], 2, "0", STR_PAD_LEFT).".yourhost.com".ZM_PATH_ZMS;

If you add this code, the only thing you have to change is pixie to match your subdomain and yourhost.com to your domain. Hope this helps someone. Feel free to pick my code apart and give suggestions on more effective ways to accomplish the same thing. =)

@knight-of-ni

This comment has been minimized.

Copy link
Member

commented Feb 28, 2015

Manipulating your hosts file to make different names resolve to the same ip address is not a solution we can implement.

@frankc420

This comment has been minimized.

Copy link

commented Feb 28, 2015

The solution I posted has nothing to do with a hosts file.

You would have to create DNS entries for each subdomain. In my case I made pixie01 - pixie15 point to my main ip.

The browser should allow 5 active connections to each host, giving you roughly 75 active cams (live view) at one time. Obviously there are other limitations, like Apache/nginx max connections, bandwidth, server resources, etc that may limit the browser from viewing a lot of cams but with the above code the limitation is no longer the code.

@knight-of-ni

This comment has been minimized.

Copy link
Member

commented Feb 28, 2015

Yes, it does.
A host file = poor mans dns
It doesn't matter if you do it in a host file or add A records to a dns server. What you are asking for cannot be done programmatically by zoneminder. That is called malware.

You can certainly set that up manually on your own lan, but that is not something we can implement.

Think about it....
If you have a zoneminder server that some random person on some random web browser connects to .... how do you expect zoneminder to manipulate the dns server that the client is using?

@Tim-Craig

This comment has been minimized.

Copy link
Contributor

commented Feb 28, 2015

Websockets is a solution to the browswer connection limit issue.
http://www.html5rocks.com/en/tutorials/websockets/basics/

The basic idea behind websockets is the browse maintains a single, bi-directional connection with the server. If the ZM ajax is replaced with websockts will cut down on the connections termendously (as ZM makes a lot of ajax calls to do things like highlight montiors in alert status on the montage, update event's in monitor view, update the fps in monitorview, etc).

Unfortunally I susspect the the browsers count the mjpeg streaming as a conenction. So we will still hit the connection limit in the montage view. If there is a solid javascript mpjeg streaming solution availible then ZM can switch to that and instead of using IMG tag and he can have a complete solution to the browser connection limit.

Websockets are supported on most browsers, with IE lagging behind as ususal. There is no offical PHP websocket support but are a number of open 3rd-party libraries. So a websocket support in zoneminder would need to be an optional feature.

@frankc420

This comment has been minimized.

Copy link

commented Feb 28, 2015

Knnniggett your messing with me right? Can you take a step back and re-read my original post. Not once did I say to add anything to a local hosts file, so I'm not sure why your hung up on that notion. Nor did I say, Zoneminder will handle this for you. I was clear, in my eyes, that DNS records needed to be created, that point to your main up, before implementing the code.

My code was implemented for public access, not local. Maybe that's where you came up with the local hosts file idea.

@knight-of-ni

This comment has been minimized.

Copy link
Member

commented Feb 28, 2015

You are taking pieces of what I say out of context and failing to look at the big picture. A hosts file is just another form of dns. Whether we are talking about a text file with name/ip references or a server running dns that does the exact same thing, the answer does not change. It doesn't matter how you do it.

Will this clear things up?
Manipulating your DNS records to make different names resolve to the same ip address is not a solution we can implement.

I'm sure there is a solution to this issue out there, but the one you have proposed is not it. I'm not trying to be mean about it, and I really do appreciate you taking the time to suggest it. However, the answer is still no.

The solution is likely going to be something along the lines of what @Tim-Craig mentioned. It will be entirely self-contained within zoneminder and not require external changes.

It may also be possible that this might become a non-issue as we develop our video branch.

@frankc420

This comment has been minimized.

Copy link

commented Feb 28, 2015

Well I can tell you, I'm able to view every camera at once in montage, which during testing was 45. Before making this mod I was only able to see 4 or 5.

The browser limitation is per hostname, not IP, which is why my implementation works, at least for what I wanted to accomplish.

Maybe it will be useful for someone else, if not, it's just more wasted bytes online.

@knight-of-ni

This comment has been minimized.

Copy link
Member

commented Mar 1, 2015

Yes, I completely understand what you are doing, and I could see from your first post that it would work for you an possibly a few others. If you feel so included, you could even make a new wiki entry describing it.

However, the immediate work around to this problem is to simply use Firefox. It has a default limit of 6 streams, but it can easily be changed. Here is the wiki entry for it:
http://www.zoneminder.com/wiki/index.php/FAQ#I_have_several_monitors_configured_but_when_I_load_the_Montage_view_in_FireFox_why_can_I_only_see_two.3F_or.2C_Why_don.27t_all_my_cameras_display_when_I_use_the_Montage_view_in_FireFox.3F

As you can see from previous posts in this thread, this capability is not available in Chrome (by design apparently), and I don't think I ever looked for this capability in IE w/cambozola (but I'm not optimistic it will work).

Because there is an existing work around to this known issue and we have other long term projects that will change the way we stream, we have not given this particular issue a high priority.

There are only three of us who you could call active developers who do this part time. There is not enough manpower to go around to solve every issue that comes in, and we have to make decisions on what gets worked on and what doesn't.

@kylejohnson

This comment has been minimized.

Copy link
Member

commented Mar 2, 2015

If my understanding of HTTP2 is correct, and as HTTP2 is now approved, and as both apache and nginx are either currently or will shortly support HTTP2, this issue may soon become moot.

@knight-of-ni knight-of-ni changed the title Suggested solution for Chrome connection Limit Work around web browser connection limits Oct 1, 2015
@pliablepixels

This comment has been minimized.

Copy link
Member

commented Jan 31, 2016

@connortechnology - reflecting back on your comment on IRC a few days ago. Were you suggesting launching zms on different ports and ZM clients (browsers, zmNinja etc) directly making a TCP connection to zms side-stepping apache? Won't this be a firewall setup issue for most people wanting WAN access?

@kylejohnson

This comment has been minimized.

Copy link
Member

commented Jan 31, 2016

Yup, it would be. You'd either need some kind of tunnel (ssh), a vpn, or a middle man (ffserver).

@pliablepixels

This comment has been minimized.

Copy link
Member

commented Jan 31, 2016

I see. Then not sure this is a good option to pursue

@knight-of-ni

This comment has been minimized.

Copy link
Member

commented Jan 31, 2016

I'm sure there is a way to do this w/o any downsides. I think this would just take someone to spend more time researching other possibilities.

@triDcontrols

This comment has been minimized.

Copy link

commented Mar 9, 2017

Any update to this? Topic was brought up 2 years ago and we're still in the same boat today, There is no argument chrome has the bigger pie of the browser market, and to reconfigure client browsers is not recommended. Upon an update Firefox restores the connection back to 6. Now we are talking blocking security updates from Firefox.

@frankc420

This comment has been minimized.

Copy link

commented Mar 9, 2017

@tridiumcontrols I could help you out with this limitation if your interested.

@triDcontrols

This comment has been minimized.

Copy link

commented Mar 9, 2017

Sure am Frank, how do we go about this?

@frankc420

This comment has been minimized.

Copy link

commented Mar 9, 2017

@tridiumcontrols Back in Feb 2015 I posted in this thread a server side workaround to the issue. It hasn't been updated for later versions of ZM, but it may not need to be. If you need help implementing, go to my Github profile and shoot me an email.

@connortechnology

This comment has been minimized.

Copy link
Member

commented Mar 10, 2017

Can't view any of your repositories

@triDcontrols

This comment has been minimized.

Copy link

commented Mar 13, 2017

Don't see any repos from your profile like Isaac has stated, but emailed you as well.

Seems like Safari for Mac or iOS do not have this limitation, only FF, Chrome, as well as I.E.

@SteveGilvarry

This comment has been minimized.

Copy link
Member

commented Mar 13, 2017

FYI note he said check GitHub profile and email. Solution will be as posted then, running multiple hosts.
#441 (comment)

@frankc420

This comment has been minimized.

Copy link

commented Mar 13, 2017

@SteveGilvarry thanks! @tridiumcontrols I've emailed you back with details.

@x2416

This comment has been minimized.

Copy link

commented May 24, 2018

I followed frankc420 suggestion, but I implemented it differently.

inside the /etc/apache2/ports.conf I added

Listen 12345
Listen 12346
Listen 12347
Listen 12348
Listen 12349
Listen 12350
Listen 12351
Listen 12352

And then in /usr/share/zoneminder/www/includes/functions.php

I found the getImageStream function and modified the return '<img id= line to look like

  $port = rand(12345, 12352);
  return '<img id="'.$id.'" src="http://'.$_SERVER['HTTP_HOST'].':'.$port.$src.'"

This way, everytime it outputs a img tag with a stream, it's randomly selecting a port (which works the same as frank's suggestion of using multiple hostnames, I just didn't want to fart with DNS).

👍

@pliablepixels

This comment has been minimized.

Copy link
Member

commented May 24, 2018

This feature (using multiple ports to avoid the max connection limit per domain) is already part of 1.31.xx - its an option called MIN_STREAMING_PORT. Enabling that + Apache config does exactly this. No further ZM code change required

@frankc420

This comment has been minimized.

Copy link

commented May 24, 2018

Here is a decent article that outlines how to enable it:
https://medium.com/zmninja/multi-port-storage-areas-and-more-d5836a336c93

@x2416

This comment has been minimized.

Copy link

commented May 24, 2018

Perfect, but I'm on ubuntu and apt-get install zoneminder installs 1.30.4, so....

I'm just happy I don't have to switch to firefox.

@stale

This comment has been minimized.

Copy link

commented Jul 23, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.