Error 403 Uploading System Files
-
I'm trying to build a smart script for updating printers using the DuetRRF Cura Plugin. Basically you read in a zip file that matches the file structure of the SD card and it transfers all of the system files to the appropriate locations and then runs the m997. Everything seems to be working ok, but about 90% of the way through uploading the files, I get an error 403, server replied: Service Unavailable.
Can you tell me what that error means or how I might avoid it?
Thanks in advance!
-
So you're using the Cura plugin to upload a zip file?
-
@phaedrux kinda, but I'm unzipping the file in a modified version of the cura plugin and uploading the files one at a time.
-
Maybe a question for the plugin author @resam
-
@roseg0ld how did you manage to convince (my) DuetRRF Cura Plugin to upload ZIP files?! It should only upload valid gcode files generated by Cura during slicing of your model...
Or are you re-using part of the source code to implement new functionality? If so, please post some code snippets so we can take a look at what you are doing, and what you are trying to do.
-
@resam I definitely didn't do it from your plugin, I've been ripping apart your source code to try and do this. It's definitely been a 'learn as I go' kind of experience so please forgive any noob errors! Here's what I'm working with:
def updatePrinter(self): self._stage = OutputStage.ready self.writeStarted.emit(self) #receive the zip name zipdata = self._updatePath with zipfile.ZipFile(zipdata, "r") as zip_ref: with tempfile.TemporaryDirectory() as folder: for info in zip_ref.infolist(): self.updProg+=1 self._onConfigUpdateProgress(self.updProg) extracted_path = zip_ref.extract(info.filename, path = folder) path = os.path.normpath(info.filename) pathList = path.split(os.sep) base = pathList[0] filename = pathList[-1] Logger.log('i',"extracting and uploading "+base)#info.filename) with open(extracted_path, 'rb') as fileobj: i+=1 Logger.log("i","uploading item: "+info.filename) self._fileName = info.filename self.configData = fileobj.read() self.onDataReady() Logger.log('d','uploaded file '+str(i)) Logger.log('d','All Done') def onDataReady(self): self._streamer = BytesIO() self._stage = OutputStage.writing self.writeStarted.emit(self) try: self._streamer.write(self.configData) except: Logger.log('e', 'file write failed: ' +str(traceback.format_exc())) Logger.log("d", self._name_id + " | Connecting...") if self._use_rrf_http_api: Logger.log('d','connecting') self._send('rr_connect', query=[("password", self._printer_password), self._timestamp()], next_stage=self.systemUpload, ) else: Logger.log('d','connecting') self._send('machine/status', next_stage=self.systemUpload, ) def systemUpload(self, other): Logger.log("d", self._name_id + " | Uploading... | "+str(self._fileName)) self._streamer.seek(0) self._posterData = QByteArray() self._posterData.append(self._streamer.getvalue()) if self._use_rrf_http_api: self._send('rr_upload', query=[("name", "0:/" + self._fileName)], next_stage = self._sysUploadDone, data=self._posterData, ) else: self._send('machine/file/' + self._fileName, next_stage = self._sysUploadDone, data=self._posterData, method='PUT', ) def _sysUploadDone(self,other): Logger.log('d',"hooray!") self.configData = None
-
@roseg0ld is your Duet running with SBC?
maybe the duetcontrolserver logs provide a clue why/when/where it fails?
see the two commands at the bottom of https://github.com/Duet3D/DuetSoftwareFramework#reporting-issues and https://github.com/Duet3D/DuetSoftwareFramework/wiki/REST-APIare you sure the error code you are receiving is 403 and not 503?
-
-
@chrishamm @resam Looking back at my logs, it seems to be uploading all of the files, on the last file in the list it seems to complete but then it gets stuck in a loop trying to reupload that final file over and over again before returning:
UM.TaskManagement.HttpRequestManager._onRequestError [374]: request[73c4e4b3][post][PyQt5.QtCore.QUrl('http://10.1.10.64/rr_upload?name=0%3A%2Fmenu%2Fscripts%2FmaterialChangeScripts%2FchangeP')][timeout=None][b'; System f'...] got an error 403, Error transferring http://10.1.10.64/rr_upload?name=0%3A%2Fmenu%2Fscripts%2FmaterialChangeScripts%2FchangeP - server replied: Service Unavailable
-
@roseg0ld What firmware version are you using? AFAIR there was a meanwhile ancient firmware version that output HTTP code 403 instead of 503, but it must be a few years old.
-
@chrishamm This was all done on RepRapFirmware for Duet 3 Mini 5+ 3.3, so definitely nothing ancient!
-
@roseg0ld Do you have a password set?
-
@chrishamm nope!
-
@roseg0ld In standalone mode RRF 3.3 reports HTTP code 503 with "Service Unavailable", so no idea why the PyQt module turns it into HTTP code 403. Do you ever read the response back from the rr_upload? It should return
{"err":0}
after every request. Also, do you have a DWC session open while uploading the files and do you get any unusual messages in the console? -
@chrishamm I got rather frustrated with this process, I can go back and check to let you know if you like. However I realized that DWC handles zip files really well, putting all the files in their appropriate places. Would it be possible to replicate this using the bare bones @resam put in the DuetRRF plugin but uploading a zip file to 0:/sys? It seems easier to troubleshoot uploading a single zip file rather than each file individually!
-
403 error is an HTTP code status code that implies that accessing a web page you were trying to reach is forbidden for some other reason.