-
Notifications
You must be signed in to change notification settings - Fork 44
Description
Hi
I'm trying to start a print with a X1E (Fw version: 01.02.00.00) using the print_3mf.py example changing printer.connect with printer.mqtt_start but I'm facing a problem with FTP and printer.upload_file function
After sending the file correctly I have an 426 error from FTP server
I attached the log (mixed between apis and ftplib)
2025-12-19 05:16:50 - bambulabs_api - INFO - Connecting to FTP server...
get '220 (vsFTPd 3.0.3)\n'
resp '220 (vsFTPd 3.0.3)'
cmd 'USER bblp'
put 'USER bblp\r\n'
get '331 Please specify the password.\n'
resp '331 Please specify the password.'
cmd 'PASS ********'
put 'PASS ********\r\n'
get '230 Login successful.\n'
resp '230 Login successful.'
2025-12-19 05:16:51 - bambulabs_api - INFO - Connected to FTP server
cmd 'PBSZ 0'
put 'PBSZ 0\r\n'
get '200 PBSZ set to 0.\n'
resp '200 PBSZ set to 0.'
cmd 'PROT P'
put 'PROT P\r\n'
get '200 PROT now Private.\n'
resp '200 PROT now Private.'
2025-12-19 05:16:51 - bambulabs_api - INFO - 200 PROT now Private.
cmd 'TYPE I'
put 'TYPE I\r\n'
get '200 Switching to Binary mode.\n'
resp '200 Switching to Binary mode.'
cmd 'PASV'
put 'PASV\r\n'
get '227 Entering Passive Mode (192,168,28,11,195,101).\n'
resp '227 Entering Passive Mode (192,168,28,11,195,101).'
cmd 'STOR file.gcode.3mf'
put 'STOR file.gcode.3mf\r\n'
get '150 Ok to send data.\n'
resp '150 Ok to send data.'
get '426 Failure reading network stream.\n'
resp '426 Failure reading network stream.'
2025-12-19 05:16:52 - bambulabs_api - ERROR - Failed to execute function: 426 Failure reading network stream.
2025-12-19 05:16:52 - bambulabs_api - INFO - Connection to FTP server closed
I see the code in ftp_client.py and the problem is in the storbinary function when the connection is closed but not unwrapped
def storbinary(self, cmd, fp, blocksize=8192, callback=None, rest=None):
self.voidcmd('TYPE I')
conn = self.transfercmd(cmd, rest)
try:
while 1:
buf = fp.read(blocksize)
if not buf:
break
conn.sendall(buf)
if callback:
callback(buf)
# shutdown ssl layer
if isinstance(conn, ssl.SSLSocket):
# conn.unwrap() # Fix for storbinary waiting indefinitely for response message from server # noqa
pass
finally:
conn.close() # This is the addition to the previous comment.
return self.voidresp()
If I uncomment the conn.unwrap() function (or use directly the original one of ftplib) it works without problems