jneilliii / OctoPrint-RTMPStreamer

22 stars 13 forks source link

HTTP Err 401 #17

Closed Sparkyz92 closed 5 years ago

Sparkyz92 commented 5 years ago

HTTP error 401 Unauthorized http://10.0.0.135/webcam/?action=stream: Server returned 401 Unauthorized Is Haproxy or something getting in the way? how can I help you help me? I was SSH'd into my pi adding the plugin and running the lines of code for docker when it hit me the error, Sorry its messy was on my phone. pi3 trying to stream to restream which goes to twitch and youtube for me.

                     Successfully built d6e5e015109a Successfully tagged octoprint/rtmpstreamer:latest pi@octopi:~/rtmpstreamer $ docker run --privileged --name RTMPStreamer -ti octoprint/rtmpstreamer:latest http://10.0.0.135/webcam/?action=stream 640x480 5 rtmp://us-west.restream.io/live_re_116815_898db4ae2b30a0b847f2 null OctoPrint Webcam Stream: http://10.0.0.135/webcam/?action=stream Stream Resolution: 640x480 Framerate 5 Stream URL posting to: rtmp://us-west.restream.io/live_re_116815_898db4ae2b30a0b847f2 ffmpeg version N-90990-g652b857b94 Copyright (c) 2000-2018 the FFmpeg developers built with gcc 6.3.0 (Raspbian 6.3.0-18+rpi1+deb9u1) 20170516 configuration: --arch=armel --target-os=linux --enable-gpl --enable-omx --enable-omx-rpi --enable-nonfree libavutil 56. 18.100 / 56. 18.100 libavcodec 58. 19.101 / 58. 19.101 libavformat 58. 13.101 / 58. 13.101 libavdevice 58. 4.100 / 58. 4.100 libavfilter 7. 21.100 / 7. 21.100 libswscale 5. 2.100 / 5. 2.100 libswresample 3. 2.100 / 3. 2.100 libpostproc 55. 2.100 / 55. 2.100 [http @ 0x33b8ba0] HTTP error 401 Unauthorized http://10.0.0.135/webcam/?action=stream: Server returned 401 Unauthorized (authorization failed)

Successfully built d6e5e015109a Successfully tagged octoprint/rtmpstreamer:latest pi@octopi:~/rtmpstreamer $ docker run --privileged --name RTMPStreamer -ti octoprint/rtmpstreamer:latest http://10.0.0.135/webcam/?action=stream 640x480 5 rtmp://us-west.restream.io/live_re_116815_898db4ae2b30a0b847f2 null OctoPrint Webcam Stream: http://10.0.0.135/webcam/?action=stream Stream Resolution: 640x480 Framerate 5 Stream URL posting to: rtmp://us-west.restream.io/live_re_116815_898db4ae2b30a0b847f2 ffmpeg version N-90990-g652b857b94 Copyright (c) 2000-2018 the FFmpeg developers built with gcc 6.3.0 (Raspbian 6.3.0-18+rpi1+deb9u1) 20170516 configuration: --arch=armel --target-os=linux --enable-gpl --enable-omx --enable-omx-rpi --enable-nonfree libavutil 56. 18.100 / 56. 18.100 libavcodec 58. 19.101 / 58. 19.101 libavformat 58. 13.101 / 58. 13.101 libavdevice 58. 4.100 / 58. 4.100 libavfilter 7. 21.100 / 7. 21.100 libswscale 5. 2.100 / 5. 2.100 libswresample 3. 2.100 / 3. 2.100 libpostproc 55. 2.100 / 55. 2.100 [http @ 0x33b8ba0] HTTP error 401 Unauthorized http://10.0.0.135/webcam/?action=stream: Server returned 401 Unauthorized (authorization failed)

jneilliii commented 5 years ago

Do you have a custom haproxy config that requires authentication?

Sparkyz92 commented 5 years ago

yes, followed HTTP authentication on haproxy Foosel's guide, is the line in there about webcam causing the issue? I'm using an insecure-password.

frontend public bind *:80 bind 0.0.0.0:443 ssl crt /etc/ssl/snakeoil.pem option forwardfor except 127.0.0.1 acl Auth_OctoPrintUsers http_auth(OctoPrintUsers) http-request auth realm OctoPrint if !Auth_OctoPrintUsers use_backend webcam if { path_beg /webcam/ } default_backend octoprint errorfile 503 /etc/haproxy/errors/503-no-octoprint.http

jneilliii commented 5 years ago

Can you link me the instructions you followed? From what I can tell with that haproxy config it looks like you are applying auth to the whole realm, not just the backends. There may be a way to bypass that for local access from the pi itself or there might be a way to embed the login information in the webcam url like http://<username>:<passowrd>@10.0.0.135/webcam/?action=stream, I just don't know and am not familiar enough with haproxy to give you a definitive answer, but that is definitely the problem.

Sparkyz92 commented 5 years ago

https://discourse.octoprint.org/t/how-to-enable-http-authentication-on-haproxy/180 I read down in the comments i think I found something that will work im going to try. I did try to put the auth info before the ip just like that before i wrote this but it didn't work. you're right about the backends and i think thats the solution. Thanks for coding the plugin :3

jneilliii commented 5 years ago

Yep, the comment you mentioned was going to be my next recommendation. Let me know how it works out for you in case someone else asks about it.