OctoPrint regularly loses connection to the printer with a "SerialException"

What is the problem?
OctoPrint regularly loses the connection to the printer with a "Servial Exception" which stops the print.

What did you already try to solve it?
I tried everything from # OctoPrint randomly loses connection to the printer with a "SerialException".
I have a good power supply, there are no other USB devices, nothing else is using the printer, I've tried different cables and reinstalled Octoprint.
Adding dwc_otg.speed=1 to /boot/cmdline.txt also didn't work.

Logs

Recv: ok
Send: N1728 G0 F3000 X9.963 Y94.815*69
Unexpected error while reading serial port, please consult octoprint.log for details: SerialException: 'device reports readiness to read but returned no data (device disconnected or multiple access on port?)' @ comm.py:_readline:2823
Please see https://faq.octoprint.org/serialerror for possible reasons of this.
Changing monitoring state from "Printing" to "Offline (Error: SerialException: 'device reports readiness to read but returned no data (device disconnected or multiple access on port?)' @ comm.py:_readline:2823)"
Connection closed, closing down monitor

Additional information about your setup
I'm running the latest OctoPrint version on a Raspberry Pi 3 B connected to an Ender5 with TH3D Firmware.

It has been running fine for weeks but now the error occurs every print, maximum 15 minutes in.
Any tips for further troubleshooting would be much appreciated.

I have another Printer (Prusa mk3s connected to Octoprint on Raspi 4 4GB)) which was running finde while the ender was having troubles.

This night they both failed stopped in an overnight print, one with the serial exception the other with:
Offline (Error: Too many consecutive timeouts, printer still connected and alive?)

Could it be a problem with the main power, so a UPS might help? Power is stable here though and the ~5 other raspis around the flat don't have any issues.

Any ideas would be much appreciated, I don't want to go back to swapping SD cards.:frowning:

UPS arrived today. First three short prints where fine, then the fourth one got a serial exception after two minutes of printing... :confused: So my last idea with, power issues, can be ruled out as well.

Have you tried to swap the Raspi between the two printers?

Yes, after the second post I tried swapping them, and tried another raspberry I had laying around, same issue :confused:

So the issue is always with the same printer regardless which Raspi is connected to them?

Are the serial devices for both printers the same e.g. /dev/ttyUSB0?

If both answers are yes, the problem seems to be the printer. Maybe you should visit a forum dedicated to its type.

I also had the problem of OctoPi 0.17 on Pi 4 disconnecting from the printer. I had Octoprint runnuing for month on a PCEngines APU1 without hickups, but needed something smaller. After a bunch of cursed spells to the Pi I saw some weird color glitches in the stream from my attached webcam. So I changed the settings of my webcam (Logitech C270) to run at 1280x960 with 25 frames/second instead of 30 frames/second. On the old installation the same camera ran at 1280x720 25fps...
Since then, a week ago, no more disconnects...

Hth