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

    Error 403 Uploading System Files

    Scheduled Pinned Locked Moved
    Third-party software
    5
    16
    698
    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.
    • roseg0ldundefined
      roseg0ld @resam
      last edited by

      @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
      
      resamundefined 1 Reply Last reply Reply Quote 0
      • resamundefined
        resam @roseg0ld
        last edited by

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

        chrishammundefined 1 Reply Last reply Reply Quote 0
        • chrishammundefined
          chrishamm administrators @resam
          last edited by

          @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

          roseg0ldundefined 1 Reply Last reply Reply Quote 0
          • roseg0ldundefined
            roseg0ld @chrishamm
            last edited by roseg0ld

            @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
            
            chrishammundefined 1 Reply Last reply Reply Quote 0
            • chrishammundefined
              chrishamm administrators @roseg0ld
              last edited by

              @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

              roseg0ldundefined 1 Reply Last reply Reply Quote 0
              • roseg0ldundefined
                roseg0ld @chrishamm
                last edited by

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

                chrishammundefined 1 Reply Last reply Reply Quote 0
                • chrishammundefined
                  chrishamm administrators @roseg0ld
                  last edited by

                  @roseg0ld Do you have a password set?

                  Duet software engineer

                  roseg0ldundefined 1 Reply Last reply Reply Quote 0
                  • roseg0ldundefined
                    roseg0ld @chrishamm
                    last edited by

                    @chrishamm nope!

                    chrishammundefined 1 Reply Last reply Reply Quote 0
                    • chrishammundefined
                      chrishamm administrators @roseg0ld
                      last edited by

                      @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

                      roseg0ldundefined 1 Reply Last reply Reply Quote 0
                      • roseg0ldundefined
                        roseg0ld @chrishamm
                        last edited by

                        @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
                        • aksnesaurora302undefined
                          aksnesaurora302
                          last edited by

                          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