scottlamb / moonfire-nvr

Moonfire NVR, a security camera network video recorder
Other
1.22k stars 137 forks source link

live view doesn't work if no sub stream is configured #119

Open IronOxidizer opened 3 years ago

IronOxidizer commented 3 years ago

Live view does not work for cameras with no sub stream configured. The result is a black screen and the following error on FireFox

Firefox can’t establish a connection to the server at ws://192.168.1.64:8080/api/cameras/7b2c7111-09c8-42a0-bdcd-ac1439133371/sub/live.m4s. LiveCamera.tsx:85:14
door: aborting due to ws close: 1006 

It's caused by this line:

https://github.com/scottlamb/moonfire-nvr/blob/8465b49cfab5561886c9ccea848cb38ef6907ba1/server/src/web.rs#L420

Potential solutions could be:

I'm not sure if this is expected behavior, but it should at least be documented.

scottlamb commented 3 years ago

Good point. I added a note to the troubleshooting doc for the moment. Long-term, I want it to support both streams; there's a bullet point about this at #115.

scottlamb commented 3 years ago

I'm calling this a JS bug in that the Javascript has all the information to know in advance that the sub stream doesn't exist and the main stream does.

It'd be nice if the server reported an error in a way the client Javascript could actually see—maybe accepting the WebSocket, sending a text message with an error, then closing it—rather than a HTTP status that the browser deliberately withholds from the Javascript. But given that the error is avoidable (ignoring silly edge cases like the server being reconfigured to take away the sub stream between the loading /api/ and loading /api/cameras/.../sub/live.m4s), I think that's a secondary concern.