switch to websocket for live stream (#59)

The multipart stream / hanging GET approach worked in a prototype for a
single stream, but Chrome has a per-host limit of six connections. If I
try streaming all my cameras at once, I hit that limit. I can't open all
the streams, much less additional connections to load init segments and
such. Websockets apparently has a much higher limit of 256.
This commit is contained in:
Scott Lamb
2020-02-28 21:41:31 -08:00
parent 3fa48ab0da
commit 92266612b5
6 changed files with 223 additions and 87 deletions

View File

@@ -198,6 +198,11 @@ upstream moonfire {
server 127.0.0.1:8080;
}
map $http_upgrade $connection_upgrade {
default Upgrade;
'' close;
}
server {
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
@@ -209,6 +214,10 @@ server {
# try_files $uri $uri/ =404;
}
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
@@ -256,5 +265,9 @@ Login with the credentials you added through `moonfire-nvr config` in the
[previous guide](install.md). You should see your username and "logout" in the
upper-right corner of the web interface.
Also try the live streaming feature, which requires WebSockets. The nginx
configuration above includes sections derived from nginx's [NGINX as a
WebSocket Proxy](https://www.nginx.com/blog/websocket-nginx/) doc.
If it doesn't work as expected, re-read this guide, then open an issue on
github for help.