Browse Source

Fix A1/A1 Mini FTP by skipping SSL on data channel entirely

  The previous fix only skipped SSL session reuse for A1 printers but
  still wrapped the data channel in SSL. VREmma's testing (issue #31)
  showed that A1 printers need the data channel to not be SSL-wrapped
  at all - they timeout waiting for transfer completion responses.

  The fix:
  - X1C/P1S: SSL with session reuse on data channel (required by vsFTPd)
  - A1/A1 Mini: No SSL on data channel (control channel remains encrypted)

  This matches VREmma's working fix (c723f25) which set ftplib._SSLSocket
  to None, but implemented properly within the ImplicitFTP_TLS class.

  Fixes #31
  Thanks VREmma!
maziggy 4 months ago
parent
commit
82a6025eeb
2 changed files with 22 additions and 24 deletions
  1. 3 3
      CHANGELOG.md
  2. 19 21
      backend/app/services/bambu_ftp.py

+ 3 - 3
CHANGELOG.md

@@ -30,9 +30,9 @@ All notable changes to Bambuddy will be documented in this file.
   - Applies to: 3MF archiving, print uploads, timelapse downloads, firmware updates
   - Applies to: 3MF archiving, print uploads, timelapse downloads, firmware updates
   - Helps P1S, X1C, and other printers with weak WiFi connections
   - Helps P1S, X1C, and other printers with weak WiFi connections
 - **A1/A1 Mini FTP fix** - Resolved FTP upload failures on A1 series printers:
 - **A1/A1 Mini FTP fix** - Resolved FTP upload failures on A1 series printers:
-  - A1 printers don't support SSL session reuse on data connections
-  - Automatic detection and workaround for A1 and A1 Mini models
-  - Maintains full encryption while skipping problematic session reuse
+  - A1 printers have issues with SSL on the FTP data channel
+  - Automatic detection skips data channel SSL for A1 and A1 Mini models
+  - Control channel remains encrypted via implicit FTPS (port 990)
   - Fixes "read operation timed out" errors during file uploads
   - Fixes "read operation timed out" errors during file uploads
 
 
 ### Fixed
 ### Fixed

+ 19 - 21
backend/app/services/bambu_ftp.py

@@ -15,10 +15,12 @@ T = TypeVar("T")
 
 
 
 
 class ImplicitFTP_TLS(FTP_TLS):
 class ImplicitFTP_TLS(FTP_TLS):
-    """FTP_TLS subclass for implicit FTPS (port 990) with optional session reuse.
+    """FTP_TLS subclass for implicit FTPS (port 990) with model-specific SSL handling.
 
 
-    SSL session reuse is required by X1C/P1S printers (vsFTPd), but causes issues
-    with A1/A1 Mini printers. Set skip_session_reuse=True for A1 printers.
+    X1C/P1S printers (vsFTPd) require SSL with session reuse on the data channel.
+    A1/A1 Mini printers have issues with SSL on the data channel entirely and
+    timeout waiting for transfer completion. Set skip_session_reuse=True for A1
+    printers to skip SSL on the data channel (control channel remains encrypted).
     """
     """
 
 
     def __init__(self, *args, skip_session_reuse: bool = False, **kwargs):
     def __init__(self, *args, skip_session_reuse: bool = False, **kwargs):
@@ -49,27 +51,23 @@ class ImplicitFTP_TLS(FTP_TLS):
         return self.welcome
         return self.welcome
 
 
     def ntransfercmd(self, cmd, rest=None):
     def ntransfercmd(self, cmd, rest=None):
-        """Override to wrap data connection in SSL.
+        """Override to wrap data connection in SSL for X1C/P1S only.
 
 
-        Session reuse is required by X1C/P1S (vsFTPd) but breaks A1/A1 Mini printers.
-        When skip_session_reuse is True, we still encrypt the data channel but
-        don't reuse the control connection's session.
+        X1C/P1S printers (vsFTPd) require SSL session reuse on the data channel.
+        A1/A1 Mini printers have issues with SSL on the data channel entirely -
+        they timeout waiting for the transfer completion response. For A1, we
+        skip SSL wrapping on the data channel (control channel remains encrypted).
         """
         """
         conn, size = FTP.ntransfercmd(self, cmd, rest)
         conn, size = FTP.ntransfercmd(self, cmd, rest)
-        if self._prot_p:
-            if self.skip_session_reuse:
-                # A1/A1 Mini: Don't reuse session (causes timeouts/hangs)
-                conn = self.ssl_context.wrap_socket(
-                    conn,
-                    server_hostname=self.host,
-                )
-            else:
-                # X1C/P1S: Reuse SSL session (required by vsFTPd)
-                conn = self.ssl_context.wrap_socket(
-                    conn,
-                    server_hostname=self.host,
-                    session=self.sock.session,
-                )
+        if self._prot_p and not self.skip_session_reuse:
+            # X1C/P1S: Wrap data channel with SSL session reuse (required by vsFTPd)
+            conn = self.ssl_context.wrap_socket(
+                conn,
+                server_hostname=self.host,
+                session=self.sock.session,
+            )
+        # A1/A1 Mini (skip_session_reuse=True): Don't wrap data channel in SSL
+        # The control channel remains encrypted via implicit FTPS
         return conn, size
         return conn, size