Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StorageException: The server has terminated the upload session #435

Closed
davidkiss opened this issue May 14, 2019 · 4 comments
Closed

StorageException: The server has terminated the upload session #435

davidkiss opened this issue May 14, 2019 · 4 comments
Assignees

Comments

@davidkiss
Copy link

[READ] Step 1: Are you in the right place?

Issues filed here should be about bugs in the code in this repository.
If you have a general question, need help debugging, or fall into some
other category use one of these other channels:

  • For general technical questions, post a question on StackOverflow
    with the firebase tag.
  • For general Firebase discussion, use the firebase-talk
    google group.
  • For help troubleshooting your application that does not fall under one
    of the above categories, reach out to the personalized
    Firebase support channel.

[REQUIRED] Step 2: Describe your environment

  • Android Studio version: 3.3___
  • Firebase Component: Storage___ (Database, Firestore, Storage, Functions, etc)
  • Component version: 16.1.0___

[REQUIRED] Step 3: Describe the problem

I'm testing resuming uploads after application crash using the uploadSessionUri on Android.

Steps to reproduce:

  1. Start uploading a ~100MB file (I used the one at http://ipv4.download.thinkbroadband.com/100MB.zip)
  2. Capture uploadSessionUri in the OnProgressListener
  3. Kill android app at around 63% of the upload progress
  4. Re-start uploading the same file with the uploadSessionUri
  5. Kill android app at around 95% of the upload progress
  6. Re-start uploading the same file with the uploadSessionUri
  7. Upload will fail with below message.
E/StorageException: StorageException has occurred.
    An unknown error occurred, please check the HTTP result code and inner exception for server response.
     Code: -13000 HttpResult: 200
    The server has terminated the upload session
    java.io.IOException: The server has terminated the upload session
        at com.google.firebase.storage.UploadTask.recoverStatus(com.google.firebase:firebase-storage@@16.1.0:354)
        at com.google.firebase.storage.UploadTask.run(com.google.firebase:firebase-storage@@16.1.0:200)
        at com.google.firebase.storage.StorageTask.lambda$getRunnable$7(com.google.firebase:firebase-storage@@16.1.0:1106)
        at com.google.firebase.storage.StorageTask$$Lambda$12.run(Unknown Source:2)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:764)
E/StorageException: StorageException has occurred.
    An unknown error occurred, please check the HTTP result code and inner exception for server response.
     Code: -13000 HttpResult: 200
E/StorageException: The server has terminated the upload session
    java.io.IOException: The server has terminated the upload session
        at com.google.firebase.storage.UploadTask.recoverStatus(com.google.firebase:firebase-storage@@16.1.0:354)
        at com.google.firebase.storage.UploadTask.run(com.google.firebase:firebase-storage@@16.1.0:200)
        at com.google.firebase.storage.StorageTask.lambda$getRunnable$7(com.google.firebase:firebase-storage@@16.1.0:1106)
        at com.google.firebase.storage.StorageTask$$Lambda$12.run(Unknown Source:2)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:764)

Sample uploadSessionUri (replaced project id with *s):
https://firebasestorage.googleapis.com/v0/b/******.appspot.com/o?name=df5b204c-2fc4-4ba2-8a25-12ab49358b71&uploadType=resumable&upload_id=AEnB2UozHoy4Qc-NELH15b1lNn-0VdzPy_izMWX5WsNTXmxuDDruk-KxYhHT44eCSr8PKxqU0YnXc_IsgTJ9PzB1bdFqBP8sCw&upload_protocol=resumable

Relevant Code:

public class UploadFile {
    public enum State { STARTING, IN_PROGRESS, SUCCESS, FAILED, TIMEDOUT, CANCELLED, PAUSED };
    private String uid;
    private String fileUri;
    private String fileName;
    private String parentRef;
    private String contentType;
    private String resumeUri;
    private State state;
    private long bytesTransferred;
    private long totalBytes;
    private long createdAt;
    private long lastUpdatedAt;

// ... getters and setters
}

            public UploadTask createUploadTask(UploadFile uploadFile) {
                Log.i(TAG, "Uploading file: " + uploadFile);
                final String fileId = uploadFile.getUid();
                StorageMetadata metadata = new StorageMetadata.Builder().build();

                return mStorageRef.child(fileId).putFile(
                        Uri.parse(uploadFile.getFileUri()), metadata,
                        uploadFile.getResumeUri() == null ? null : Uri.parse(uploadFile.getResumeUri()));
            }

@google-oss-bot
Copy link
Contributor

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

@schmidt-sebastian
Copy link
Contributor

schmidt-sebastian commented May 21, 2019

@davidkiss Thanks for filing this issue! Can you confirm (via the Firebase Console for example) that the upload did not succeed? The error you are reporting is thrown by the Storage SDK when GCS's "X-Goog-Upload-Status" is set to "final", indicating that the upload is no longer pending.

@davidkiss
Copy link
Author

@schmidt-sebastian I can confirm the file appears in Firebase Console. So upload completed, but the OnProgressListener just wasn't triggered yet?

@schmidt-sebastian
Copy link
Contributor

All of our notifications are triggered asynchronously, and the progress handler does not fire for the "100% progress" event. Instead, we will call the completion handler. If you don't kill your app right away, you should see the completion handler fire.

@firebase firebase locked and limited conversation to collaborators Oct 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants