motioneye-project / motioneyeos

A Video Surveillance OS For Single-board Computers
Other
7.83k stars 898 forks source link

RPi Zero W: mjpg client connection closed, camera feed freezes #2241

Open Ultrabenosaurus opened 4 years ago

Ultrabenosaurus commented 4 years ago

Preliminary Docs

I confirm that I have read the CONTRIBUTING guide before opening this issue.

I confirm that I have read the FAQ before opening this issue.

motionEyeOS Version

I am running motionEyeOS version: 20190911

Board Model

I am using the following board/model: Raspberry Pi Zero W

Camera

I am using the following type of camera: V4L2 Camera

My camera model is: Microsoft LifeCam VX-800

Network Connection

My motionEyeOS unit is connected to the network via: WiFi

Peripherals

I am using the following peripherals that I consider relevant to this issue:

Log Files

I consider the following log files relevant to this issue:

Issue

I have my Zero W simply hosting the camera and streaming it (640*480 @ 10fps) over WiFi to a Pi 3B running motionEye on Raspbian, which actually does motion detection and everything else. Occasionally it stops working as the camera feed has frozen. Sometimes logging into the Zero W web UI fixes it, sometimes it doesn't and I have to reboot the Zero W.

Note: it never shows any error or acts as though the feed is dead, it just keeps showing the last frame it received.

The only trace of the problem I can find is this line in the Zero W's motioneye.log file, which gets repeated anywhere from once per hour to a dozen times per hour until I either log in to the web UI or reboot it.

WARNING: mjpg client connection for camera 1 on port 8081 is closed

Looking at the timestamps, it might be freezing for short periods on a regular basis and then only "permanently" freeing every few days. However, I often notice that I don't get a notification (via a script I wrote on the 3B that goes via IFTTT) when I leave for work in the morning or get home in the evening. When I open the 3B's web UI after getting home from work it will show a frame from early morning before I left for work, or my car will still be missing from the driveway as it froze some time after I left the house. On days I'm not at work I'll check the feed on my PC at say 9am, but it'll show pitch black because it froze some time during the night.

I have noticed that keeping a browser tab open for either web UI (Zero W or 3B) helps reduce the occurrences, but this is not a 100% guarantee and it does still freeze on occasion. It is also not feasible as I run both devices without a monitor and don't want to leave my PC running 24/7 just to keep a browser tab open in the hope it might keep my camera running.

If motionEyeOS knows to write the WARNING line into the logs, can't it also bump / force the mjpg connection?

Ultrabenosaurus commented 4 years ago

I've set a cron job on my Pi 3B to run curl -I http://<pi_zero_w>/ & every 5 minutes which seems to help a bit. I have also invested in the official 7" touchscreen for my Pi 3B which automatically opens the Pi 3B's web interface in a full screen browser on boot, so the feed is constantly active and I can check it instantly whenever I'm in the house. Both the Zero W and the 3B add a timestamp to the camera feed, so I can easily tell if one of them has frozen.

However I am still experiencing random freezes. Just today I got home from work a little after 17:30 but got no notification that the camera had seen my drive up to the house. When I checked the feed from my Pi 3B web interface the view was of my empty driveway and the timestamp from the Zero W stream was stuck at 11:46 and some seconds.