octocitrico
octocitrico copied to clipboard
Problems with webcam and HAProxy
I can't manage my camera "Logitech C170" to run on OPi PC
pi@citrico-opipc:~$ systemctl status webcamd.service
● webcamd.service - the OctoPi webcam daemon with the user specified config
Loaded: loaded (/etc/systemd/system/webcamd.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2022-04-20 16:48:21 UTC; 2min 53s ago
Process: 1320 ExecStart=/root/bin/webcamd (code=exited, status=0/SUCCESS)
Main PID: 1367 (mjpg_streamer)
Tasks: 2 (limit: 2065)
Memory: 984.0K
CPU: 270ms
CGroup: /system.slice/webcamd.service
└─1367 ./mjpg_streamer -o output_http.so -w ./www-octopi -n --listen 127.0.0.1 -i input_uvc.so -r 1024x768 -d /dev/video1
pi@citrico-opipc:~$ sudo journalctl -u webcamd.service
I need to start manually the webcamd.service even it is enabled in scripts/citrico-config But i still have error "Webcam stream not loaded" LED on webcam isn't lit
Also i can't establish connection with Octoprint on web browser without typing port 5000 because the HAProxy won't work:
pi@citrico-opipc:~$ systemctl status haproxy.service
● haproxy.service - HAProxy Load Balancer
Loaded: loaded (/lib/systemd/system/haproxy.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2022-04-20 17:08:40 UTC; 25s ago
Docs: man:haproxy(1)
file:/usr/share/doc/haproxy/configuration.txt.gz
Process: 1813 ExecStartPre=/usr/sbin/haproxy -f $CONFIG -c -q $EXTRAOPTS (code=exited, status=1/FAILURE)
CPU: 43ms
pi@citrico-opipc:~$ sudo journalctl -u haproxy.service
Journal file /var/log/journal/f9e625e74d4d4da38d1b700f20eef421/system.journal is truncated, ignoring file.
-- Journal begins at Sat 2022-03-26 13:38:38 UTC, ends at Wed 2022-04-20 17:10:03 UTC. --
Mar 26 13:39:15 citrico-opipc systemd[1]: Starting HAProxy Load Balancer...
Mar 26 13:39:16 citrico-opipc haproxy[1559]: [ALERT] 084/133916 (1559) : parsing [/etc/haproxy/haproxy.cfg:25] : 'bind :::443' : unable to load certificate from file '/etc/ssl/snakeoil.pem'.
Mar 26 13:39:16 citrico-opipc haproxy[1559]: [ALERT] 084/133916 (1559) : parsing [/etc/haproxy/haproxy.cfg:35] : The 'reqrep' directive is not supported anymore since HAProxy 2.1. Use 'http-request r>
Mar 26 13:39:16 citrico-opipc haproxy[1559]: [ALERT] 084/133916 (1559) : parsing [/etc/haproxy/haproxy.cfg:36] : The 'reqadd' directive is not supported anymore since HAProxy 2.1. Use 'http-request a>
Mar 26 13:39:16 citrico-opipc haproxy[1559]: [ALERT] 084/133916 (1559) : parsing [/etc/haproxy/haproxy.cfg:37] : The 'reqadd' directive is not supported anymore since HAProxy 2.1. Use 'http-request a>
Mar 26 13:39:16 citrico-opipc haproxy[1559]: [ALERT] 084/133916 (1559) : parsing [/etc/haproxy/haproxy.cfg:43] : The 'reqrep' directive is not supported anymore since HAProxy 2.1. Use 'http-request r>
Mar 26 13:39:16 citrico-opipc haproxy[1559]: [ALERT] 084/133916 (1559) : Error(s) found in configuration file : /etc/haproxy/haproxy.cfg
Mar 26 13:39:16 citrico-opipc haproxy[1559]: [ALERT] 084/133916 (1559) : Fatal errors found in configuration.
Mar 26 13:39:16 citrico-opipc systemd[1]: haproxy.service: Control process exited, code=exited, status=1/FAILURE
Mar 26 13:39:16 citrico-opipc systemd[1]: haproxy.service: Failed with result 'exit-code'.
Mar 26 13:39:16 citrico-opipc systemd[1]: Failed to start HAProxy Load Balancer.
I'm using latest release v22-02-1
Ok, problems with HAProxy gone after editing /etc/haproxy/haproxy.cfg and paste this config https://github.com/guysoft/OctoPi/blob/devel/src/modules/octopi/filesystem/root/etc/haproxy/haproxy.2.x.cfg
Camera still not work, but when i plug PS Eye camera it works like a charm /video3 PS Eye /video1 C170
Apr 21 18:30:53 citrico-opipc systemd[1]: Started the OctoPi webcam daemon with the user specified config.
Apr 21 18:32:28 citrico-opipc systemd[1]: Stopping the OctoPi webcam daemon with the user specified config...
Apr 21 18:32:28 citrico-opipc systemd[1]: webcamd.service: Succeeded.
Apr 21 18:32:28 citrico-opipc systemd[1]: Stopped the OctoPi webcam daemon with the user specified config.
Apr 21 18:32:28 citrico-opipc systemd[1]: Starting the OctoPi webcam daemon with the user specified config...
Apr 21 18:32:28 citrico-opipc mjpg_streamer[3027]: MJPG-streamer [3027]: starting application
Apr 21 18:32:28 citrico-opipc mjpg_streamer[3027]: MJPG-streamer [3027]: MJPG Streamer Version.: 2.0
Apr 21 18:32:28 citrico-opipc mjpg_streamer[3027]: MJPG-streamer [3027]: Using V4L2 device.: /dev/video1
Apr 21 18:32:28 citrico-opipc mjpg_streamer[3027]: MJPG-streamer [3027]: Desired Resolution: 1024 x 768
Apr 21 18:32:28 citrico-opipc mjpg_streamer[3027]: MJPG-streamer [3027]: Frames Per Second.: -1
Apr 21 18:32:28 citrico-opipc mjpg_streamer[3027]: MJPG-streamer [3027]: Format............: JPEG
Apr 21 18:32:28 citrico-opipc mjpg_streamer[3027]: MJPG-streamer [3027]: TV-Norm...........: DEFAULT
Apr 21 18:32:28 citrico-opipc mjpg_streamer[3027]: MJPG-streamer [3027]: www-folder-path......: ./www-octopi/
Apr 21 18:32:28 citrico-opipc mjpg_streamer[3027]: MJPG-streamer [3027]: HTTP TCP port........: 8080
Apr 21 18:32:28 citrico-opipc mjpg_streamer[3027]: MJPG-streamer [3027]: HTTP Listen Address..: 127.0.0.1
Apr 21 18:32:28 citrico-opipc mjpg_streamer[3027]: MJPG-streamer [3027]: username:password....: disabled
Apr 21 18:32:28 citrico-opipc mjpg_streamer[3027]: MJPG-streamer [3027]: commands.............: disabled
Apr 21 18:32:28 citrico-opipc mjpg_streamer[3027]: MJPG-streamer [3027]: starting input plugin input_uvc.so
Apr 21 18:32:28 citrico-opipc mjpg_streamer[3027]: MJPG-streamer [3027]: starting output plugin: output_http.so (ID: 00)
Apr 21 18:32:28 citrico-opipc mjpg_streamer[3027]: MJPG-streamer [3027]: Can't enable video in first time
Apr 21 18:32:28 citrico-opipc mjpg_streamer[3027]: MJPG-streamer [3027]: cleaning up resources allocated by input thread
Apr 21 18:32:29 citrico-opipc systemd[1]: Started the OctoPi webcam daemon with the user specified config.
Apr 21 18:33:27 citrico-opipc systemd[1]: Stopping the OctoPi webcam daemon with the user specified config...
Apr 21 18:33:27 citrico-opipc systemd[1]: webcamd.service: Succeeded.
Apr 21 18:33:27 citrico-opipc systemd[1]: Stopped the OctoPi webcam daemon with the user specified config.
Apr 21 18:33:27 citrico-opipc systemd[1]: Starting the OctoPi webcam daemon with the user specified config...
Apr 21 18:33:27 citrico-opipc mjpg_streamer[3076]: MJPG-streamer [3076]: starting application
Apr 21 18:33:27 citrico-opipc mjpg_streamer[3076]: MJPG-streamer [3076]: MJPG Streamer Version.: 2.0
Apr 21 18:33:27 citrico-opipc mjpg_streamer[3076]: MJPG-streamer [3076]: Using V4L2 device.: /dev/video3
Apr 21 18:33:27 citrico-opipc mjpg_streamer[3076]: MJPG-streamer [3076]: Desired Resolution: 1024 x 768
Apr 21 18:33:27 citrico-opipc mjpg_streamer[3076]: MJPG-streamer [3076]: Frames Per Second.: 1
Apr 21 18:33:27 citrico-opipc mjpg_streamer[3076]: MJPG-streamer [3076]: Format............: YUYV
Apr 21 18:33:27 citrico-opipc mjpg_streamer[3076]: MJPG-streamer [3076]: JPEG Quality......: 80
Apr 21 18:33:27 citrico-opipc mjpg_streamer[3076]: MJPG-streamer [3076]: TV-Norm...........: DEFAULT
Apr 21 18:33:27 citrico-opipc mjpg_streamer[3076]: MJPG-streamer [3076]: www-folder-path......: ./www-octopi/
Apr 21 18:33:27 citrico-opipc mjpg_streamer[3076]: MJPG-streamer [3076]: HTTP TCP port........: 8080
Apr 21 18:33:27 citrico-opipc mjpg_streamer[3076]: MJPG-streamer [3076]: HTTP Listen Address..: 127.0.0.1
Apr 21 18:33:27 citrico-opipc mjpg_streamer[3076]: MJPG-streamer [3076]: username:password....: disabled
Apr 21 18:33:27 citrico-opipc mjpg_streamer[3076]: MJPG-streamer [3076]: commands.............: disabled
Apr 21 18:33:27 citrico-opipc mjpg_streamer[3076]: MJPG-streamer [3076]: starting input plugin input_uvc.so
Apr 21 18:33:27 citrico-opipc mjpg_streamer[3076]: MJPG-streamer [3076]: starting output plugin: output_http.so (ID: 00)
Apr 21 18:33:28 citrico-opipc systemd[1]: Started the OctoPi webcam daemon with the user specified config.
I tried differnt parameters and i still can't get it to work.
haproxy.2.x.cfg
do you have a copy of this file? [haproxy.2.x.cfg] because is not available
Sure
global
maxconn 4096
user haproxy
group haproxy
log /dev/log local1 debug
tune.ssl.default-dh-param 2048
defaults
log global
mode http
compression algo gzip
option httplog
option dontlognull
retries 3
option redispatch
option http-server-close
option forwardfor
maxconn 2000
timeout connect 5s
timeout client 15m
timeout server 15m
frontend public
bind :::80 v4v6
bind :::443 v4v6 ssl crt /etc/ssl/snakeoil.pem
option forwardfor except 127.0.0.1
use_backend webcam if { path_beg /webcam/ }
use_backend webcam_hls if { path_beg /hls/ }
use_backend webcam_hls if { path_beg /jpeg/ }
default_backend octoprint
backend octoprint
acl needs_scheme req.hdr_cnt(X-Scheme) eq 0
http-request replace-path ^([^\ :]*)\ /(.*) \1\ /\2
http-request add-header X-Scheme https if needs_scheme { ssl_fc }
http-request add-header X-Scheme http if needs_scheme !{ ssl_fc }
option forwardfor
server octoprint1 127.0.0.1:5000
errorfile 503 /etc/haproxy/errors/503-no-octoprint.http
backend webcam
http-request replace-path /webcam/(.*) /\1
server webcam1 127.0.0.1:8080
errorfile 503 /etc/haproxy/errors/503-no-webcam.http
backend webcam_hls
server webcam_hls_1 127.0.0.1:28126
errorfile 503 /etc/haproxy/errors/503-no-webcam-hls.http
For camera configuration check this resource: https://community.octoprint.org/docs?topic=21149 HA proxy fix is implemented and will be ready in the next release.