EliasKotlyar / Xiaomi-Dafang-Hacks

4.19k stars 1k forks source link

Camera loosing web, mqtt etc. #1719

Closed tb205gti closed 3 years ago

tb205gti commented 3 years ago

I have a very wierd issue with one of my cameras - it is the only that has this behaviour out of 8.

After some time I cannot reach the webinterface at all - nothing is listening on either port 80 or 443. It still streams via RTSP, but does not detect night/day changes at all. if I nmap the camera I can see that the only open port is 22. However - it will not accept my ssh password at all. Only way to recover is to reboot the camera.

The camera is running: 2019-09-19T16:48:28Z, Camera is Dafang.

I do not have logs as I cannot reach the camera viw SSH when the issue is in effect.

pmogas commented 3 years ago

The same here.

marek2k commented 3 years ago

I have the same issue. Such entries appear in the log

[root@DAFANG:]# tail /tmp/lighttpd-error.log
2021-04-22 09:58:48: (mod_cgi.c.813) fork failed: Cannot allocate memory
2021-04-22 09:58:49: (mod_cgi.c.813) fork failed: Cannot allocate memory
2021-04-22 09:58:54: (mod_cgi.c.813) fork failed: Cannot allocate memory
gstrauss commented 3 years ago

Do you know what version of lighttpd is running? If lighttpd exits due to out-of-memory, is there a supervisor that restarts it?

marek2k commented 3 years ago

My camera is updated to latest firmware version

Model: | Xiaomi Xiaofang 1S
Firmware date: | 2021-04-22T16:59:23Z
Firmware Branch: | master
Firmware Commit: | 1de5ae1 ( No update available)
Kernel Version: | #32 PREEMPT Wed Jan 24 02:40:56 CST 2018
Bootloader Version: | U-Boot 2013.07 (Jul 05 2018 - 17:59:02)
...

[root@XIAOFANG:sdcard]# tail /tmp/lighttpd-error.log 2021-04-23 09:19:47: (server.c.1488) server started (lighttpd/1.4.56-devel-lighttpd-1.4.55-1-g2230b08e) 2021-04-23 09:52:08: (mod_cgi.c.813) fork failed: Cannot allocate memory 2021-04-23 09:52:13: (mod_cgi.c.813) fork failed: Cannot allocate memory 2021-04-23 09:52:57: (mod_cgi.c.813) fork failed: Cannot allocate memory 2021-04-23 09:52:57: (mod_cgi.c.813) fork failed: Cannot allocate memory

gstrauss commented 3 years ago

Can you post the lighttpd.conf? lighttpd -f /etc/lighttpd/lighttpd.conf -p

When lighttpd reports "Cannot allocate memory" due to fork failing, that suggests that the system has run out of memory, perhaps by having too many instances of the target CGI program running.

If the system is resource-limited, you might want to limit the number of simultaneous connections with this in lighttpd.conf server.max-connections = 4 (or even 1)

FYI: latest lighttpd is lighttpd 1.4.59

Does your system logs (e.g. /var/log/messages) have any reports of the kernel OOM killer killing processes using too much memory? (Or are these logs kept in memory and are lost when the camera is rebooted?)

marek2k commented 3 years ago

My lighttpd.conf is exactly the same as lighttpd.conf.dist https://raw.githubusercontent.com/EliasKotlyar/Xiaomi-Dafang-Hacks/master/firmware_mod/config/lighttpd.conf.dist

My problem has begun after updating to the latest firmware. Previously installed firmware that worked properly had the old UI.

gstrauss commented 3 years ago

lighttpd.conf.dist looks reasonable to me.

This might be an issue with the CGI program rather than with lighttpd. I am a lighttpd developer and happened across this issue, so I figured I'd ask a few questions. Presumably this firmware update included an upgrade to lighttpd 1.4.56, so I was curious if the issue was related to lighttpd or not. Based on my reading of the simple lighttpd.conf.dist, the issue is probably elsewhere.

jmtatsch commented 3 years ago

Yes there are so many areas where memory could be mismanaged. My guess would be the mqtt handling which reconnects for every message 🤫 thanks for creating/maintaining lighttpd 👍🏻

JonyBCN commented 3 years ago

I have a very wierd issue with one of my cameras - it is the only that has this behaviour out of 8.

After some time I cannot reach the webinterface at all - nothing is listening on either port 80 or 443. It still streams via RTSP, but does not detect night/day changes at all. if I nmap the camera I can see that the only open port is 22. However - it will not accept my ssh password at all. Only way to recover is to reboot the camera.

The camera is running: 2019-09-19T16:48:28Z, Camera is Dafang.

I do not have logs as I cannot reach the camera viw SSH when the issue is in effect.

Same Here. After a couple of reboots its working again.

stale[bot] commented 3 years ago

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.