appsup-dart / firebase_dart

A pure Dart implementation of the Firebase client
Other
91 stars 30 forks source link

Connection error doesnt respond as onError #22

Open worldwidee opened 2 years ago

worldwidee commented 2 years ago

WhatsApp Image 2022-01-30 at 23 40 20 WhatsApp Image 2022-01-30 at 23 37 48

Sometimes i get these errors while uploading data to firebase storage. However when i put UploadTask in try catch block, catch part doesnt work and also when i listen uploadtask onError part doesnt work too. For example it doesnt print "upload get err1 or err2".

try {
      uploadTask = ref.putData(File(file.filePath).readAsBytesSync());
      await uploadTask.snapshotEvents.listen((snapshot) {
        uploadingValue =
            ((snapshot.bytesTransferred / snapshot.totalBytes) * 100).toInt() /
                100;
        print('Progress: %${uploadingValue * 100}');
      }, onDone: () async {
        print("UPLOAD DONE!!!");
        print("uploadFail:$cloudFail");
        if (!cloudFail) {
          setState(() {
            uploaded = true;
          });
          await triggerStorageFiles();
          saveDb();
        }
      }, onError: (e) {
        print("upload get err1:$e");
        cancellUpload();
        cloudFail = true;
        saveDb();
      });
    } catch (e) {
      print("upload get err2:$e");
    }

By the way its happening while connected wifi. I dont get this err when i connected with cable.

Edit: same error Unhandled Exception: SocketException: OS Error: Operation timed out, errno = 60, address = firebasestorage.googleapis.com, port = 51294 its happening while uploading big file or 20-30 small files. So i think its becoming timed out with wifi connection. How can i fix it :(