salim-lachdhaf / dartFTP

dartFTP
MIT License
9 stars 17 forks source link

Facing error socketException: Connection reset by peer (OS Error: Connection reset by peer, errno = 54) on ios #25

Open aqueebqazi opened 1 year ago

aqueebqazi commented 1 year ago

Hi I am facing the above error when uploading multiple files 4to 5 files on ios emulator iphone 14 pro ios v 16.4. Below is the code for (int i = 0; i < file.length; i++) {

        // await ftpConnect.connect();

Future.delayed(Duration(seconds: 2),(){ log("delay started"); }); log("delay ended");

        currentIndex = i;
        if (cancelUpload.value == false && isUploadSucess.value == false) {
          log("lenfth of file" + file.length.toString());
          log("current file path:" + file[i].path);
          File files = File(file[i].path);
          log("current file path ---->> :" + files.path);
          log("current file paths before uploading :" +
              tabController1.file.toString());

          await ftpConnect.uploadFile(
            File(file[i].path),
            supportIPV6: false,
          );
          double data1 = fileCount.value.toDouble();
          showFileCount.value = data1.toString();
          //increase the value of file by one when the file is uploaded sucessfully
          //below code is to calculate upload percent
          log("file count" + fileCount.value.toString());
          showUploadPercentage.value = uploadPercent.value;
          //uploading xml file
          String fileName = p.basename(file[i].path).split('.').first;
          // remove extension from file name
          // fileName = fileName.substring(0, fileName.lastIndexOf('.'));
          //faster way

          final myxmlFile = File('$_dirPath/${fileName}.xml');
          log("XML FILE NAME >>>> ${myxmlFile.path}");
          await myxmlFile.writeAsString(document.toXmlString(pretty: true));
          await ftpConnect.uploadFile(myxmlFile);
          fileCount.value++;
          uploadPercent.value =
              (fileCount.value.toDouble() / totalcount) * 100;
          double data = fileCount.value.toDouble();
          showFileCount.value = data.toString();
          log("file count" + fileCount.value.toString());
          log("totalFileCount" + totalFileCount.value.toString());
          log("upload percent" + uploadPercent.value.toString());
          log("above sucess" + uploadPercent.value.toString());
          showUploadPercentage.value = uploadPercent.value;
          // await ftpConnect.disconnect();
          if (showUploadPercentage.value == 100.0) {
            Wakelock.disable();
            isUploadSucess.value = true;
            Fluttertoast.showToast(
                msg: "Successfully Uploaded".tr,
                gravity: ToastGravity.CENTER);

            log("upload was" + isUploadSucess.toString());
          }
        } else if (cancelUpload.value == true) {
          Fluttertoast.showToast(
              msg: "Upload was canceled", gravity: ToastGravity.CENTER);
        }
      }
aqueebqazi commented 1 year ago

The code works fine on android.

salim-lachdhaf commented 6 months ago

the code seems correct for me

salim-lachdhaf commented 6 months ago

have you a simple to reproduce the issue ?