Setting up OctoPrint on a Raspberry Pi running Raspberry Pi OS (Debian)

I'm setting this up on a debian linux laptop, so I'm not using a Pi. I'm providing this info for others if they run into this issue.

I had issues with the haproxy configuration since things apparently change after a certain version. I'm running version 2.2.9-1

While this probably doesn't affect the Pi, it might eventually.

I got these warnings and errors:

[WARNING] 051/085546 (3107) : unexpected character 'i' after the timer value '15min', only (us=microseconds,ms=milliseconds,s=seconds,m=minutes,h=hours,d=days) are supported. This will be reported as an error in next versions.
[WARNING] 051/085546 (3107) : unexpected character 'i' after the timer value '15min', only (us=microseconds,ms=milliseconds,s=seconds,m=minutes,h=hours,d=days) are supported. This will be reported as an error in next versions.
[NOTICE] 051/085546 (3107) : haproxy version is 2.2.9-1
[NOTICE] 051/085546 (3107) : path to executable is /usr/sbin/haproxy
[ALERT] 051/085546 (3107) : parsing [/etc/haproxy/haproxy.cfg:28] : The 'reqrep' directive is not supported anymore since HAProxy 2.1. Use 'http-request replace-path', 'http-request replace-uri' or 'http-request replace-header' instead.
[ALERT] 051/085546 (3107) : parsing [/etc/haproxy/haproxy.cfg:33] : The 'reqrep' directive is not supported anymore since HAProxy 2.1. Use 'http-request replace-path', 'http-request replace-uri' or 'http-request replace-header' instead.
[ALERT] 051/085546 (3107) : Error(s) found in configuration file : /etc/haproxy/haproxy.cfg
[ALERT] 051/085546 (3107) : Fatal errors found in configuration.

I fixed it by changing the haproxy.cfg to:

global
        maxconn 4096
        user haproxy
        group haproxy
        daemon
        log 127.0.0.1 local0 debug

defaults
        log     global
        mode    http
        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
        use_backend webcam if { path_beg /webcam/ }
        default_backend octoprint

backend octoprint
        http-request replace-path ^([^\ :]*)\ /(.*)     \1\ /\2
        option forwardfor
        server octoprint1 127.0.0.1:5000

backend webcam
        http-request replace-path /webcam/(.*) /\1
        server webcam1  127.0.0.1:8080

I found these changes at Making OctoPi build on Ubuntu 64bit so we have 64bit builds Β· Issue #711 Β· guysoft/OctoPi Β· GitHub

I have installed OctoPrint according to the guide at the top of this page and everything appeared to go without any errors or warnings. I setup autostart according to the guide and the service starts on bootup and can be restarted, stopped and started by the appropriate commands. The only problem is when opening the web interface I get nothing. No feedback no nothing. It just times out. I have been using OctoPrint for 4 or 5 years and always installed from the octopi image. This time I did not want to erase my pi. The browser I am using is running another instance of OctoPrint on a seperate rPi. I am using winSCP and Putty to investigate as these are headless

The command "ps -ef | grep -i octoprint | grep -i python" returns:
pi 1966 101 4.3 144592 38796 ? Ssl 15:56 0:04 /home/pi/OctoPrint/venv/bin/python3 /home/pi/OctoPrint/venv/bin/octoprint
pi 1981 0.0 1.7 22644 15344 ? R 15:56 0:00 /home/pi/OctoPrint/venv/bin/python3 -m pip --version
The command "curl -D - localhost:5000" puts out more than 100 pages of HTML.

Hopefully someone may take a look at this info and be able to help an old man out. Thanks for any insight provided.

octoprint.log (117.4 KB)

I'm at the point where when I click Test for the Snapshot URL, I get a snapshot of what the webcam is seeing.

When I click Test for the Stream URL, however, I don't see what the webcam sees.

How would I go about fixing this :confused:

Thanks!

What URLs have you entered?

Stream URL: /webcam/?action=stream

Snapshot URL: http://127.0.0.1:8080/?action=snapshot

I'm running Octoprint, manual installation, on a Thinkpad running kubuntu. The camera is generic.

Thanks for the reply.

You probably need to check the haproxy section then, since the webcam URL is using that.

If you try http://your-ip:8080/?action=stream, it should work because this is not using haproxy. However, to avoid the port and make it relative you need that proxy section complete.

1 Like

So I put in the full link that you posted and now it's working.

http://192.168.1.3:8080/?action=stream

Thanks!

I just did a setup on a clean install to a Pi 4.

These are the steps I used to get it up and running as it is slightly different to what is listed above.

sudo apt update -y
sudo apt full-upgrade -y
sudo apt install python3-pip python3-dev python3-setuptools python3-venv git libyaml-dev build-essential -y
pip3 install virtualenv
sudo reboot

mkdir OctoPrint && cd OctoPrint
virtualenv --python=python3 venv
source venv/bin/activate
pip install octoprint

//Test

~/OctoPrint/venv/bin/octoprint serve

//Setup Octoprint Via GUI you should be able to see some info in the console.
//Once setup is complete.
//End Octoprint

CTRL+C

The rest of the guide works well :slight_smile:

1 Like

Hi, I'm stuck on the haproxy.cfg sample. I can't edit it, showing an error "Failed to save document. Permission denied." How can I edit and save the haproxy.cfg file?

A little late, but run the edit command as

sudo <whatever editor you're using> haproxy.cfg

That gives the editor root permission, and root can save any file anywhere.

me too bro so yeah

I am having a lot of trouble

It might help to say what you're having trouble with :wink:

Im having issues with plugins, they install okay, but after restarting the server, they are no longer installed

Please open a new topic under 'Get Help', providing as much information as possible and we will try to help you.

Why? If this is the only thing it is used for, why does it matter? Seems like running this virtually just makes it inherently use more resources?

I just got a 3D printer and I'm interested in Octoprint. Less for the video, because I have some great 2k pan and tilt cameras that give me a good view, but more so for stats.

A virtual environment is NOT a virtual machine. Think of it as a dedicated folder for the software itself and the dependencies. There's no resource overhead there, apart from a tiny amount of additional storage for some copies of the Python binaries that are miniscule.

And why? We've had too many issues with people who went "this is the only software that will run there" and then it turned out it wasn't.

3 Likes

Thanks for the quick reply. Yes, I realize it isn't a VM. Just seems like it makes it more difficult to access.

Ok, fair enough. Thanks!

Great instructions, but I'm trying to futz with my camera and /boot/octoprint.txt just isn't there.
Did I miss something? I've been running this for almost two years now, everything works and updates but the file's just not there! Is there a default somewhere I can start with? THanks!

/boot/octoprint.txt is a part of OctoPi and this guide doesn't create it or set it up. To change the mjpg-streamer settings you'd have to edit the scripts you created originally. It's possible this guide changed since you did it or that you decided to do something different, so saying exactly what/where is impossible, but starting with what the guide has for setting up mjpg-streamer to start up automatically is a good place to start.