Arksine / moonraker

Web API Server for Klipper
https://moonraker.readthedocs.io
GNU General Public License v3.0
1.08k stars 411 forks source link

Cannot send job from Cura if printer is idle after a previous print #736

Closed JollyRgrs closed 12 months ago

JollyRgrs commented 1 year ago

What happened

If the printer has been shut down since a previous print, I cannot send a new print via Cura to Moonraker without "touching" a gcode file. If I view (I don't have to save/edit) the file in the editor or simply choose "View 3D" or if I even just delete an existing gcode file, then that is enough where I can then hit "Upload to Printer" in Cura and it works. This was not an issue in the past but I cannot be sure when it became an issue as I don't always run multiple prints before my printer is shut down.

The error I get in Cura is a network connectivity, "Bad Gateway" error. Which does not seem appropriate as it worked fine for the first print and works fine after the workaround. The error in moonraker logs is: streaming_form_data.parser.ParseFailedException: _parser.data_received failed with delimiting multipart stream into parts

Again, nothing changed, just doing "something" with existing gcode files (view in 3d, view for editing, delete, etc.) is all that is required before the next attempt simply works.

Client

Other

Browser

Other or N/A

How to reproduce

Using Cura, print an item and after completion (and some minutes have passed) the printer is powered off (smart switch), now attempt to print (upload) another file via Cura.

Additional information

Cura configuration

Power Device(s) (Name configured in moonraker.conf
ender3

relevant moonraker.conf

[power ender3]
type: mqtt
# off_when_shutdown: True
# off_when_shutdown_delay: 3
on_when_job_queued: True
locked_while_printing: True
restart_klipper_when_powered: True
restart_delay: 5
bound_services:

command_topic: cmnd/3d_printer/Power
command_payload:
   {% if command == "on" %}
     1
   {% else %}
     0
   {% endif %}
state_topic: stat/3d_printer/POWER
state_resposne_template:
   {% set resp = payload|fromjson %}
   {resp["POWER"]}
state_timeout: 5
query_topic: cmnd/3d_printer/Power

moonraker.log relevant timestamp of error: 2023-10-29 16:50:05,755

-------------------- Log Start | Sun Oct 29 06:04:49 2023 --------------------
data_path: /home/jollyrgrs/printer_data
is_default_data_path: False
config_file: /home/jollyrgrs/printer_data/config/moonraker.conf
startup_warnings: []
verbose: False
debug: False
asyncio_debug: False
is_backup_config: False
is_python_package: False
instance_uuid: b5aeb85d66b241b4bcf64d5fdd544460
unix_socket_path: /home/jollyrgrs/printer_data/comms/moonraker.sock
software_version: v0.8.0-187-g17ffb44
git_branch: master
git_remote: origin
git_repo_url: https://github.com/Arksine/moonraker.git
modified_files: []
unofficial_components: []
log_file: /home/jollyrgrs/printer_data/logs/moonraker.log
python_version: 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0]
msgspec_enabled: False
uvloop_enabled: False

#################### Moonraker Configuration ####################

[secrets]

[server]
host = 0.0.0.0
port = 7125
klippy_uds_address = /home/jollyrgrs/printer_data/comms/klippy.sock

[authorization]
trusted_clients = 
    10.0.0.0/16
    10.0.0.0/8
    127.0.0.0/8
    169.254.0.0/16
    172.16.0.0/12
    192.168.0.0/16
    FE80::/10
    ::1/128
cors_domains = 
    *.lan
    *.local
    *://localhost
    *://localhost:*
    *://my.mainsail.xyz
    *://app.fluidd.xyz

[octoprint_compat]

[history]

[update_manager]
channel = dev
refresh_interval = 168

[update_manager mainsail-config]
type = git_repo
primary_branch = master
path = ~/mainsail-config
origin = https://github.com/mainsail-crew/mainsail-config.git
managed_services = klipper

[update_manager mainsail]
type = web
channel = stable
repo = mainsail-crew/mainsail
path = ~/mainsail

[update_manager crowsnest]
type = git_repo
path = ~/crowsnest
origin = https://github.com/mainsail-crew/crowsnest.git
managed_services = crowsnest
install_script = tools/pkglist.sh

[mqtt]
address = 10.0.0.30
port = 1883
username = {secrets.mqtt_credentials.username}
password = {secrets.mqtt_credentials.password}
instance_name = ender3

[power ender3]
type = mqtt
on_when_job_queued = True
locked_while_printing = True
restart_klipper_when_powered = True
restart_delay = 5
bound_services = 
command_topic = cmnd/3d_printer/Power
command_payload = 
    {% if command == "on" %}
    1
    {% else %}
    0
    {% endif %}
state_topic = stat/3d_printer/POWER
state_resposne_template = 
    {% set resp = payload|fromjson %}
    {resp["POWER"]}
state_timeout = 5
query_topic = cmnd/3d_printer/Power

[power printer_lamps]
type = mqtt
on_when_job_queued = True
locked_while_printing = False
restart_klipper_when_powered = False
command_topic = cmnd/outlet_aux/Power2
command_payload = 
    {% if command == "on" %}
    1
    {% else %}
    0
    {% endif %}
state_topic = stat/outlet_aux/POWER2
state_resposne_template = 
    {% set resp = payload|fromjson %}
    {resp["POWER2"]}
state_timeout = 5
query_topic = cmnd/outlet_aux/Power2

[update_manager mobileraker]
type = git_repo
path = /home/jollyrgrs/mobileraker_companion
origin = https://github.com/Clon1998/mobileraker_companion.git
primary_branch = main
managed_services = mobileraker
env = /home/jollyrgrs/mobileraker-env/bin/python
requirements = scripts/mobileraker-requirements.txt
install_script = scripts/install-mobileraker-companion.sh

#################################################################
All Configuration Files:
/home/jollyrgrs/printer_data/config/moonraker.conf
#################################################################
Unsafe Shutdown Count: 4

System Info:

***python***
  version: (3, 11, 2, 'final', 0)
  version_string: 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0]

***cpu_info***
  cpu_count: 4
  bits: 64bit
  processor: x86_64
  cpu_desc: Intel(R) Core(TM) i5-4570S CPU @ 2.90GHz
  serial_number: 
  hardware_desc: 
  model: 
  total_memory: 16264656
  memory_units: kB

***sd_info***

***distribution***
  name: Debian GNU/Linux 12 (bookworm)
  id: debian
  version: 12
  version_parts: {'major': '12', 'minor': '', 'build_number': ''}
  like: 
  codename: bookworm
  release_info: {}

***virtualization***
  virt_type: none
  virt_identifier: none

***network***

***canbus***

***Allowed Services***
  klipper_mcu
  webcamd
  MoonCord
  KlipperScreen
  moonraker-telegram-bot
  moonraker-obico
  sonar
  crowsnest
  octoeverywhere
  ratos-configurator
  mobileraker

Systemd unit moonraker.service:
unit_name: moonraker.service
is_default: True
manager: systemd
Properties:
**Requires=['system.slice', 'network-online.target', '-.mount', 'sysinit.target']
**After=['network-online.target', 'systemd-journald.socket', 'system.slice', '-.mount', 'basic.target', 'sysinit.target']
**SupplementaryGroups=['moonraker-admin']
**EnvironmentFiles=/home/jollyrgrs/printer_data/systemd/moonraker.env
**ExecStart=/home/jollyrgrs/moonraker-env/bin/python $MOONRAKER_ARGS
**WorkingDirectory=/home/jollyrgrs/moonraker
**FragmentPath=/etc/systemd/system/moonraker.service
**Description=API Server for Klipper SV1
**User=jollyrgrs

Systemd unit klipper.service:
unit_name: klipper.service
is_default: True
manager: systemd
Properties:
**Requires=['system.slice', '-.mount', 'sysinit.target']
**After=['sysinit.target', 'network-online.target', 'systemd-journald.socket', 'basic.target', 'system.slice', '-.mount']
**SupplementaryGroups=[]
**EnvironmentFiles=/home/jollyrgrs/printer_data/systemd/klipper.env
**ExecStart=/home/jollyrgrs/klippy-env/bin/python $KLIPPER_ARGS
**WorkingDirectory=/home/jollyrgrs/klipper
**FragmentPath=/etc/systemd/system/klipper.service
**Description=Klipper 3D Printer Firmware SV1
**User=jollyrgrs
Git Repo moonraker: No warnings detected
Git Repo klipper: Warnings detected:
  Repo has untracked source files: ['klippy/extras/gcode_shell_command.py']
Git Repo mainsail-config: No warnings detected
Git Repo crowsnest: No warnings detected
Git Repo mobileraker: No warnings detected
Klipper Version: v0.11.0-304-gf7567a0d-dirty
2023-10-29 02:04:50,001 [power.py:_on_state_update()] - MQTT Power Device printer_lamps: External Power event detected, new state: off
2023-10-29 02:05:51,137 [websockets.py:on_close()] - Websocket Closed: ID: 139871051057040 Close Code: None, Close Reason: None, Pong Time Elapsed: 6.55
2023-10-29 02:05:51,138 [websockets.py:on_close()] - Websocket Closed: ID: 139871062877648 Close Code: None, Close Reason: None, Pong Time Elapsed: 0.59
2023-10-29 11:09:15,601 [authorization.py:_check_trusted_connection()] - Trusted Connection Detected, IP: 10.0.0.222
2023-10-29 11:09:15,602 [app.py:log_request()] - 101 GET /websocket (10.0.0.222) [_TRUSTED_USER_] 0.85ms
2023-10-29 11:09:15,602 [websockets.py:open()] - Websocket Opened: ID: 139871052255952, Proxied: True, User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36, Host Name: hptouch.redacteddomain.com
2023-10-29 11:09:15,605 [websockets.py:_handle_identify()] - Websocket 139871052255952 Client Identified - Name: mainsail, Version: 2.8.0, Type: web
2023-10-29 11:09:27,738 [app.py:log_request()] - 101 GET /websocket (10.0.0.222) [_TRUSTED_USER_] 0.91ms
2023-10-29 11:09:27,738 [websockets.py:open()] - Websocket Opened: ID: 139871061770064, Proxied: True, User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36, Host Name: hptouch.redacteddomain.com
2023-10-29 11:09:27,740 [websockets.py:_handle_identify()] - Websocket 139871061770064 Client Identified - Name: mainsail, Version: 2.8.0, Type: web
2023-10-29 12:13:58,320 [authorization.py:_prune_conn_handler()] - Trusted Connection Expired, IP: 10.0.0.222
2023-10-29 13:46:14,609 [power.py:_schedule_firmware_restart()] - Power Device ender3: Sending FIRMWARE_RESTART command to Klippy
2023-10-29 13:46:19,612 [klippy_connection.py:_on_connection_closed()] - Klippy Connection Removed
2023-10-29 13:46:20,630 [app.py:log_request()] - 503 GET /printer/info (10.0.0.222) [_API_KEY_USER_] 1.89ms
2023-10-29 13:46:20,869 [klippy_connection.py:_do_connect()] - Klippy Connection Established
2023-10-29 13:46:22,894 [klippy_connection.py:_request_initial_subscriptions()] - Webhooks Subscribed
2023-10-29 13:46:22,895 [klippy_connection.py:_request_initial_subscriptions()] - GCode Output Subscribed
2023-10-29 13:46:23,145 [job_state.py:_handle_started()] - Job state initialized: standby
2023-10-29 13:46:23,400 [klippy_connection.py:_check_ready()] - Klippy ready
2023-10-29 13:46:23,671 [app.py:prepare()] - Upload Request Received from 10.0.0.222
2023-10-29 13:46:23,722 [app.py:post()] - Processing Uploaded File: /CE3E3V2_Paint_bucket_opener_v0.gcode
2023-10-29 13:46:23,783 [shell_command.py:pipe_data_received()] - INFO:metadata:Object Processing is disabled

2023-10-29 13:46:23,814 [shell_command.py:_check_proc_success()] - Command (/home/jollyrgrs/moonraker-env/bin/python /home/jollyrgrs/moonraker/moonraker/components/file_manager/metadata.py -p /home/jollyrgrs/printer_data/gcodes -f "CE3E3V2_Paint_bucket_opener_v0.gcode") successfully finished
2023-10-29 13:46:23,818 [app.py:log_request()] - 201 POST /server/files/upload (10.0.0.222) [_API_KEY_USER_] 146.98ms
2023-10-29 13:46:23,900 [job_state.py:_status_update()] - Job Started: CE3E3V2_Paint_bucket_opener_v0.gcode
2023-10-29 13:46:24,400 [data_store.py:_init_sensors()] - Configuring available sensors: ['heater_bed', 'extruder']
2023-10-29 13:46:45,290 [power.py:_on_state_update()] - MQTT Power Device printer_lamps: External Power event detected, new state: on
2023-10-29 13:48:44,949 [authorization.py:_check_trusted_connection()] - Trusted Connection Detected, IP: 10.0.0.222
2023-10-29 13:48:44,949 [app.py:log_request()] - 101 GET /websocket (10.0.0.222) [_TRUSTED_USER_] 0.64ms
2023-10-29 13:48:44,949 [websockets.py:open()] - Websocket Opened: ID: 139871062062224, Proxied: True, User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36, Host Name: hptouch.redacteddomain.com
2023-10-29 13:48:44,952 [websockets.py:_handle_identify()] - Websocket 139871062062224 Client Identified - Name: mainsail, Version: 2.8.0, Type: web
2023-10-29 14:48:58,342 [authorization.py:_prune_conn_handler()] - Trusted Connection Expired, IP: 10.0.0.222
2023-10-29 16:40:15,248 [power.py:_on_state_update()] - MQTT Power Device ender3: External Power event detected, new state: off
2023-10-29 16:40:22,442 [klippy_connection.py:_process_status_update()] - Klippy has shutdown
2023-10-29 16:40:22,443 [proc_stats.py:_handle_shutdown()] - 
Moonraker System Usage Statistics:
System Time: 1698611993.125823, Usage: 0.49%, Memory: 70536 kB
System Time: 1698611994.125987, Usage: 0.61%, Memory: 70536 kB
System Time: 1698611995.126913, Usage: 0.65%, Memory: 70536 kB
System Time: 1698611996.127824, Usage: 0.5%, Memory: 70536 kB
System Time: 1698611997.128997, Usage: 0.63%, Memory: 70536 kB
System Time: 1698611998.129904, Usage: 0.99%, Memory: 70536 kB
System Time: 1698611999.131100, Usage: 0.57%, Memory: 70536 kB
System Time: 1698612000.131944, Usage: 0.51%, Memory: 70536 kB
System Time: 1698612001.133361, Usage: 0.47%, Memory: 70536 kB
System Time: 1698612002.134110, Usage: 0.58%, Memory: 70536 kB
System Time: 1698612003.135908, Usage: 0.52%, Memory: 70536 kB
System Time: 1698612004.137848, Usage: 0.6%, Memory: 70536 kB
System Time: 1698612005.139270, Usage: 0.69%, Memory: 70536 kB
System Time: 1698612006.139995, Usage: 0.63%, Memory: 70536 kB
System Time: 1698612007.140757, Usage: 0.54%, Memory: 70536 kB
System Time: 1698612008.141698, Usage: 0.61%, Memory: 70536 kB
System Time: 1698612009.142497, Usage: 0.56%, Memory: 70536 kB
System Time: 1698612010.143125, Usage: 0.45%, Memory: 70536 kB
System Time: 1698612011.143541, Usage: 0.5%, Memory: 70536 kB
System Time: 1698612012.144562, Usage: 0.46%, Memory: 70536 kB
System Time: 1698612013.145776, Usage: 1.26%, Memory: 70536 kB
System Time: 1698612014.146820, Usage: 1.12%, Memory: 70536 kB
System Time: 1698612015.148135, Usage: 0.81%, Memory: 70536 kB
System Time: 1698612016.149460, Usage: 0.83%, Memory: 70536 kB
System Time: 1698612017.150326, Usage: 0.56%, Memory: 70536 kB
System Time: 1698612018.151006, Usage: 0.68%, Memory: 70536 kB
System Time: 1698612019.151471, Usage: 0.56%, Memory: 70536 kB
System Time: 1698612020.152351, Usage: 0.47%, Memory: 70536 kB
System Time: 1698612021.153763, Usage: 0.51%, Memory: 70536 kB
System Time: 1698612022.154630, Usage: 0.52%, Memory: 70536 kB
CPU Temperature: 27.8
2023-10-29 16:49:56,698 [power.py:_schedule_firmware_restart()] - Power Device ender3: Sending FIRMWARE_RESTART command to Klippy
2023-10-29 16:50:01,701 [klippy_connection.py:_on_connection_closed()] - Klippy Connection Removed
2023-10-29 16:50:02,714 [app.py:log_request()] - 503 GET /printer/info (10.0.0.222) [_API_KEY_USER_] 1.69ms
2023-10-29 16:50:02,957 [klippy_connection.py:_do_connect()] - Klippy Connection Established
2023-10-29 16:50:04,981 [klippy_connection.py:_request_initial_subscriptions()] - Webhooks Subscribed
2023-10-29 16:50:04,982 [klippy_connection.py:_request_initial_subscriptions()] - GCode Output Subscribed
2023-10-29 16:50:05,232 [job_state.py:_handle_started()] - Job state initialized: standby
2023-10-29 16:50:05,486 [klippy_connection.py:_check_ready()] - Klippy ready
2023-10-29 16:50:05,754 [app.py:prepare()] - Upload Request Received from 10.0.0.222
2023-10-29 16:50:05,755 [http1connection.py:__exit__()] - Uncaught exception
Traceback (most recent call last):
  File "/home/jollyrgrs/moonraker-env/lib/python3.11/site-packages/tornado/http1connection.py", line 664, in _read_fixed_body
    await ret
  File "/home/jollyrgrs/moonraker/moonraker/app.py", line 954, in data_received
    await evt_loop.run_in_thread(self._parser.data_received, chunk)
  File "/usr/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jollyrgrs/moonraker-env/lib/python3.11/site-packages/streaming_form_data/parser.py", line 82, in data_received
    raise ParseFailedException(
streaming_form_data.parser.ParseFailedException: _parser.data_received failed with delimiting multipart stream into parts
2023-10-29 16:50:06,738 [data_store.py:_init_sensors()] - Configuring available sensors: ['heater_bed', 'extruder']
2023-10-29 16:52:20,589 [websockets.py:on_close()] - Websocket Closed: ID: 139871062062224 Close Code: 1001, Close Reason: None, Pong Time Elapsed: 5.64
2023-10-29 16:52:20,817 [authorization.py:_check_trusted_connection()] - Trusted Connection Detected, IP: 10.0.0.222
2023-10-29 16:52:20,818 [app.py:log_request()] - 101 GET /websocket (10.0.0.222) [_TRUSTED_USER_] 1.11ms
2023-10-29 16:52:20,818 [websockets.py:open()] - Websocket Opened: ID: 139871051715408, Proxied: True, User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36, Host Name: hptouch.redacteddomain.com
2023-10-29 16:52:20,820 [websockets.py:_handle_identify()] - Websocket 139871051715408 Client Identified - Name: mainsail, Version: 2.8.0, Type: web
2023-10-29 16:52:34,084 [websockets.py:on_close()] - Websocket Closed: ID: 139871051715408 Close Code: 1001, Close Reason: None, Pong Time Elapsed: 3.26
2023-10-29 16:52:58,063 [app.py:prepare()] - Upload Request Received from 10.0.0.222
2023-10-29 16:52:58,314 [app.py:post()] - Processing Uploaded File: /CE3E3V2_large_cap_extension_Fixed.gcode
2023-10-29 16:52:58,374 [shell_command.py:pipe_data_received()] - INFO:metadata:Object Processing is disabled

2023-10-29 16:52:58,392 [shell_command.py:_check_proc_success()] - Command (/home/jollyrgrs/moonraker-env/bin/python /home/jollyrgrs/moonraker/moonraker/components/file_manager/metadata.py -p /home/jollyrgrs/printer_data/gcodes -f "CE3E3V2_large_cap_extension_Fixed.gcode") successfully finished
2023-10-29 16:52:58,395 [app.py:log_request()] - 201 POST /server/files/upload (10.0.0.222) [_API_KEY_USER_] 332.14ms
2023-10-29 16:52:58,432 [job_state.py:_status_update()] - Job Started: CE3E3V2_large_cap_extension_Fixed.gcode
Arksine commented 1 year ago

What version of Cura are you using, and are you using a particular plugin to communicate with Moonraker?

JollyRgrs commented 1 year ago

What version of Cura are you using, and are you using a particular plugin to communicate with Moonraker?

Sorry, I meant to include that. Currently Cura 5.5 but it happened on 5.4 as well and I believe it was working fine on 5.4, so this is why I don't think it was a change in Cura. Using Moonraker Connection 1.7.1 which was last updated back in February (the issue did not present itself until much more recently, in fact, I was still using Octoprint and Marlin back then)

JollyRgrs commented 1 year ago

To clarify, when the printer is off, Cura does properly communicate to Moonraker to turn on the switch for the printer, even when it gets the error about uploading the gcode.

Arksine commented 1 year ago

Ok, I am going to attempt to reproduce this. Until then, I have made a small change that should improve the error handling when a parse error is encountered. In the off chance that this occurs due to re-entry I have added a lock to prevent that condition, so it may be worth a test.

Moonraker uses an external dependency to parse chunked uploads and it was recently updated for compatibility with Python 3.11. Its possible that this is the source of the issue. Once I am able to repro I should be able to track it down.

dosoft commented 1 year ago

I'm encountering the same issue (with identical symptoms and the same error in the logs). This error happens repeatedly (1-2-3 times in a row), and then suddenly everything starts working correctly until the next occurrence. I haven't identified any consistent patterns.

I've experienced this problem with different versions of Cura (5.4.x, 5.5 beta1, 5.5.0)

dosoft commented 1 year ago

It's probably worth mentioning that I tested on a version WITHOUT the latest commit. I will now update and test with it.

Arksine commented 1 year ago

I believe I have tracked down the issue. The short answer is that there is a small bug in the Cura-Moonraker plugin that needs to be fixed. Below I will provide a detailed response for posterity. I'll finish by explaining why this is showing up now.

To begin, I need to provide a primer on how upload requests work. They are a type of HTTP request with a content type known as multipart/form-data. These requests may include multiple parts in the body, where each part is separated by a boundary. The boundary must be unique, so they often consist of randomly generated characters.

This boundary is specified in the Content-Type request header. The content type header received from the Cura-Moonraker Plugin might look like the following:

Content-Type: multipart/form-data; boundary=boundary_.oOo._ztoqtTuftFcXb+R3aGGtZjF/xypG1vK+

According to the multipart/form-data standard outlined in RFC 2388 and RFC 2046, the value for the boundary must be enclosed in double quotes if it contains characters such as a : or /. Indeed, when the parser attempts to extract the boundary from this header it gets truncated, resulting in a value of boundary_.oOo._ztoqtTuftFcXb+R3aGGtZjF. This is the cause of the parsing error.

When testing with [octoprint_compat] enabled and the Cura Octoprint plugin, the Content-Type header looks similar to the following:

Content-Type: multipart/form-data; boundary="boundary_.oOo._yf5SooRb+x0U4Qc1j8zJF+5pwkEBi3WN"

Notice that the value for the boundary is quoted. The parser will not truncate this value if it contains a reserved character.

The solution is either to make sure that the boundary contains no reserved characters or to quote the boundary. The author of the Cura Moonraker plugin should be able to resolve this by modifying Line 466 to add quotes around the boundary. Alternatively, rather than using the boundary generated by the QT framework, the plugin could set its own boundary that does not use reserved characters.

Why is this showing up now?

Moonraker depends on streaming-form-data to handle upload parsing. This includes everything from the Content-Type to the body of the request. The version of this dependency was recently bumped to add full support for Python 3.11.

The previous version used python's cgi module to parse the Content Type header. As the link states, the cgi module is now deprecated, and it has been recommended to use the email.message to perform this instead. The cgi module did not strictly adhere to RFC 2046, but email.message does. In other words, the cgi module was able to extract the full boundary from a request that did not adhere to the standard, but email.message truncates it.

The streaming_form_data module cannot revert back to using cgi, as it has been deprecated in Python 3.11 and scheduled for removal in Python 3.13. For the same reasons, Moonraker cannot revert back to an older version of streaming_form_data, it is necessary for Moonraker to fully support Python 3.11 with the release of Debian Bookworm. In addition, it is generally a good idea to adhere to standards.

Arksine commented 1 year ago

One last thing, while waiting for a fix from the Cura2Moonraker plugin author you may be able to temporarily get around this issue by manually forcing a downgrade via ssh. Assuming Moonraker's environment is installed at the default location, the following commands could work:

~/moonraker-env/bin/pip install streaming_form_data==1.11.0
sudo service moonraker restart

On some systems with Python 3.11 installed the wheel will fail to build, however on others it builds despite not officially supporting 3.11.

If the downgrade does work, one thing to keep in mind is that the update manager will upgrade it again the next time it detects a change to Moonraker's dependencies.

emtrax-ltd commented 1 year ago

I'll take a look at it and make the fix - publication in the Cura Marketplace will of course take 2 weeks again

emtrax-ltd commented 1 year ago

Thank you for the detailed analysis and explanation of the error/problem. I have made the fix for this and have already made it available for publication on the Cura marketplace - approval is still pending.

emtrax-ltd commented 1 year ago

Hotfix is ​​now available in the Marketplace.

JollyRgrs commented 12 months ago

Hotfix is ​​now available in the Marketplace.

I've printed a few things now and have yet to have the issue, will keep trying to see if I can get the error to come up again but so far I can't! I'll try a few more scenarios but so far I see nothing wrong.

JollyRgrs commented 12 months ago

I tried printing after waiting for the printer to turn off from idle, I tried printing before the idle timeout, I tried printing twice from Cura without closing it first. I can't recreate the issue. I'm calling this a done deal. Thanks @emtrax-ltd and @Arksine

DuckersMcQuack commented 9 months ago

Getting this issue as well. I've been using the same older version for months, decided to update, now i get this problem as well. 50-85% chance of getting the connection issue.

IIs there a way to roll back an update or 2 to the version i was on? As it gave consistent successful uploads on every attempt.

Arksine commented 9 months ago

@DuckersMcQuack As I mentioned in your original issue, you need to update the Moonraker Connection plugin in Cura.

DuckersMcQuack commented 9 months ago

@DuckersMcQuack As I mentioned in your original issue, you need to update the Moonraker Connection plugin in Cura.

Oh, ok, i see an update now. Wasn't any updates at the time of checking as of 2 or 3 days ago. Unless the newest updates only appears if i reboot the pi? As i tested that as well a few days ago.

Arksine commented 9 months ago

Oh, ok, i see an update now. Wasn't any updates at the time of checking as of 2 or 3 days ago. Unless the newest updates only appears if i reboot the pi? As i tested that as well a few days ago.

To be clear, it isn't Moonraker than requires an update, it is the linked Moonraker Connection plugin you are using in Cura.