• Tags
  • Documentation
  • Order
  • Register
  • Login
Duet3D Logo Duet3D
  • Tags
  • Documentation
  • Order
  • Register
  • Login

Error 403 Uploading System Files

Scheduled Pinned Locked Moved
Third-party software
5
16
645
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • undefined
    roseg0ld
    last edited by 13 Aug 2021, 22:38

    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!

    1 Reply Last reply Reply Quote 0
    • undefined
      Phaedrux Moderator
      last edited by 14 Aug 2021, 18:30

      So you're using the Cura plugin to upload a zip file?

      Z-Bot CoreXY Build | Thingiverse Profile

      undefined 1 Reply Last reply 20 Aug 2021, 18:34 Reply Quote 0
      • undefined
        roseg0ld @Phaedrux
        last edited by 20 Aug 2021, 18:34

        @phaedrux kinda, but I'm unzipping the file in a modified version of the cura plugin and uploading the files one at a time.

        1 Reply Last reply Reply Quote 0
        • undefined
          Phaedrux Moderator
          last edited by 20 Aug 2021, 18:52

          Maybe a question for the plugin author @resam

          Z-Bot CoreXY Build | Thingiverse Profile

          1 Reply Last reply Reply Quote 0
          • undefined
            resam
            last edited by 20 Aug 2021, 19:44

            @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.

            undefined 1 Reply Last reply 23 Aug 2021, 02:47 Reply Quote 0
            • undefined
              roseg0ld @resam
              last edited by 23 Aug 2021, 02:47

              @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
              
              undefined 1 Reply Last reply 23 Aug 2021, 19:19 Reply Quote 0
              • undefined
                resam @roseg0ld
                last edited by 23 Aug 2021, 19:19

                @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-API

                are you sure the error code you are receiving is 403 and not 503?

                undefined 1 Reply Last reply 23 Aug 2021, 19:23 Reply Quote 0
                • undefined
                  chrishamm administrators @resam
                  last edited by 23 Aug 2021, 19:23

                  @resam In SBC mode you'd get HTTP code 404, not 403.
                  @roseg0ld Do you get frequent messages in the DWC console while the upload is in progress? It does sound like you get HTTP code 503 instead of 403. That code is typically only output when the Duet runs out of memory, hence my question.

                  Duet software engineer

                  undefined 1 Reply Last reply 24 Aug 2021, 02:32 Reply Quote 0
                  • undefined
                    roseg0ld @chrishamm
                    last edited by roseg0ld 24 Aug 2021, 02:32

                    @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
                    
                    undefined 1 Reply Last reply 24 Aug 2021, 08:05 Reply Quote 0
                    • undefined
                      chrishamm administrators @roseg0ld
                      last edited by 24 Aug 2021, 08:05

                      @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.

                      Duet software engineer

                      undefined 1 Reply Last reply 27 Aug 2021, 17:17 Reply Quote 0
                      • undefined
                        roseg0ld @chrishamm
                        last edited by 27 Aug 2021, 17:17

                        @chrishamm This was all done on RepRapFirmware for Duet 3 Mini 5+ 3.3, so definitely nothing ancient!

                        undefined 1 Reply Last reply 27 Aug 2021, 17:48 Reply Quote 0
                        • undefined
                          chrishamm administrators @roseg0ld
                          last edited by 27 Aug 2021, 17:48

                          @roseg0ld Do you have a password set?

                          Duet software engineer

                          undefined 1 Reply Last reply 31 Aug 2021, 04:28 Reply Quote 0
                          • undefined
                            roseg0ld @chrishamm
                            last edited by 31 Aug 2021, 04:28

                            @chrishamm nope!

                            undefined 1 Reply Last reply 31 Aug 2021, 07:58 Reply Quote 0
                            • undefined
                              chrishamm administrators @roseg0ld
                              last edited by 31 Aug 2021, 07:58

                              @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?

                              Duet software engineer

                              undefined 1 Reply Last reply 23 Sept 2021, 23:23 Reply Quote 0
                              • undefined
                                roseg0ld @chrishamm
                                last edited by 23 Sept 2021, 23:23

                                @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!

                                1 Reply Last reply Reply Quote 0
                                • undefined
                                  aksnesaurora302
                                  last edited by 25 Sept 2021, 09:18

                                  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.

                                  1 Reply Last reply Reply Quote 0
                                  • First post
                                    Last post
                                  Unless otherwise noted, all forum content is licensed under CC-BY-SA