Camera Reconnect Issue

Forum for questions and support relating to the 1.27.x releases only.
Post Reply
Posts: 2
Joined: Tue Oct 14, 2014 5:49 pm

Camera Reconnect Issue

Post by ColbDC » Tue Oct 14, 2014 5:57 pm

I'm rolling out a new Zoneminder 1.27 server with a set of Ubiquiti AirCams and they're working reasonably well except for one issue - whenever one of them goes down, the server never reestablishes a connection to it unless I manually go into the Console, select the Source, and then save it. Looking at the logs, it appears that the system is trying to automatically reestablish the connection but might not be correctly detecting whether it's actually connected or not. I have the cameras set to use libvlc, which appears to be otherwise rock solid.

Is there a setting that I should be tweaking or something?

Code: Select all

2014-10-14 10:36:05.030464	web_php	4441	ERR	socket_sendto( /tmp/zm/zms-135921s.sock ) failed: No such file or directory	/usr/share/zoneminder/includes/functions.php	2337
2014-10-14 10:36:02.010840	web_php	32767	ERR	socket_sendto( /tmp/zm/zms-135921s.sock ) failed: No such file or directory	/usr/share/zoneminder/includes/functions.php	2337
2014-10-14 10:35:58.984897	web_php	17747	ERR	socket_sendto( /tmp/zm/zms-135921s.sock ) failed: No such file or directory	/usr/share/zoneminder/includes/functions.php	2337
2014-10-14 10:35:55.968547	web_php	12629	ERR	socket_sendto( /tmp/zm/zms-135921s.sock ) failed: No such file or directory	/usr/share/zoneminder/includes/functions.php	2337
2014-10-14 10:35:52.630710	zms	32767	ERR	Terminating, last frame sent time 1413308152.130348 secs more than maximum of 10.000000	zm_monitor.cpp	4060
2014-10-14 10:34:44.182040	zmc_m1	32767	INF	Priming capture from rtsp://user:password@XXX.XXX.XXX.XXX:554/live/ch00_0	zm_libvlc_camera.cpp	139
2014-10-14 10:34:44.181023	zmc_m1	32767	INF	Starting Capture	zmc.cpp	195
2014-10-14 10:34:44.053090	zmdc	32767	INF	'zmc -m 1' started at 14/10/14 10:34:44	
2014-10-14 10:34:44.053040	zmdc	32767	INF	'zmc -m 1' starting at 14/10/14 10:34:44, pid = 56883	
2014-10-14 10:34:44.048670	zmdc	32767	INF	Starting pending process, zmc -m 1	
2014-10-14 10:34:43.947170	zmdc	32767	INF	'zmc -m 1' crashed, signal 8	
2014-10-14 10:34:37.928383	zmc_m1	32767	INF	Got signal 15 (Terminated), exiting	zm_signal.cpp	40
2014-10-14 10:34:37.927270	zmdc	32767	INF	'zmc -m 1' stopping at 14/10/14 10:34:37	
2014-10-14 10:34:37.713870	zmwatch	32767	INF	Restarting capture daemon for 1-Camera1, time since last capture 7 seconds (1413308077-1413308070)

Posts: 2
Joined: Tue Oct 14, 2014 5:49 pm

Re: Camera Reconnect Issue

Post by ColbDC » Tue Oct 28, 2014 8:56 pm

Came up with a quick and dirty "solution" of sorts after noticing that the very bug I posted about in here already has a small bounty attached and hasn't gone anywhere (you'll have to search for it - the forum thinks the off-site link is "spamy" even though the link went straight to the Zoneminder Bountysource page). While troubleshooting the problem, I noticed that Zoneminder automatically starts a zmc daemon for each camera (zmc -m CameraNumber), which, if it successfully connects to an IP camera, spawns additional threads to process the stream. If it isn't successful, however, the daemon just sits and doesn't spawn any threads. So, I used that behavior to my advantage and wrote a script that, when plugged into cron and set to run periodically (I went with once every five minutes - note that it takes approximately 6-10 seconds for the daemon to stop and start, so time it accordingly), would check to see if there are any zmc daemons without threads (status "S" instead of "Sl") and, if there are, restart them:

Code: Select all



for i in $(ps -Czmc -oargs,stat --no-headers | tr -s [:blank:] ':'); do
        Camera=$(echo $i | awk -F: '{ print $3 }' -)
        Status=$(echo $i | awk -F: '{ print $4 }' -)
        if [[ "$Status" == "S" ]]
                echo Restarting camera $Camera
                /usr/bin/ stop zmc -m $Camera
                /usr/bin/ start zmc -m $Camera

exit 0
I'll be the first to admit that this won't win any coding awards - error checking is nonexistent and there's probably a cleaner way to get the data out of ps than what I went with, but it works. If somebody has a better implementation, I'll happily try it.

Posts: 6
Joined: Tue Jul 17, 2018 6:21 pm

Re: Camera Reconnect Issue

Post by spammy » Thu Jul 19, 2018 10:53 am

Thank you for this.

I'm having the same issue with one of my cameras, except the ps commands above seem to return S for most of the working ones too. So instead I'm just going to directly restart the camera in question using the start and stop commands.

EDIT: I ended up using the script as is, using pcpu == 0.0 instead of stat = S.

Were you able to get a better solution?

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests