StorageException: The server has terminated the upload session
[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:
- Start uploading a ~100MB file (I used the one at http://ipv4.download.thinkbroadband.com/100MB.zip)
- Capture uploadSessionUri in the OnProgressListener
- Kill android app at around 63% of the upload progress
- Re-start uploading the same file with the uploadSessionUri
- Kill android app at around 95% of the upload progress
- Re-start uploading the same file with the uploadSessionUri
- 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()));
}
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
@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.
@schmidt-sebastian I can confirm the file appears in Firebase Console. So upload completed, but the OnProgressListener just wasn't triggered yet?
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.