question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TaskCanceledException thrown when i try upload Android Application Bundle

See original GitHub issue

AndroidPublisher.v3

Code sample:

var credentials = GoogleCredential.FromFile(credentialsFile).CreateScoped(new List<string> {AndroidPublisherService.Scope.Androidpublisher});
var service = new AndroidPublisherService(new BaseClientService.Initializer
{
    HttpClientInitializer = credentials,
    ApplicationName = "Application Upload Tool"
 });

var edit = await service.Edits.Insert(new AppEdit(), packageName).ExecuteAsync();

using (var stream = new FileStream(appBundleFile, FileMode.Open, FileAccess.Read)) 
{
    var uploadRequest = service.Edits.Bundles.Upload(packageName, edit.Id, stream, "application/octet-stream");
    uploadRequest.ProgressChanged += UploadRequestOnProgressChanged;
    await uploadRequest.UploadAsync();
}

i wrote simple ProgressChanged event handler:

private static void UploadRequestOnProgressChanged(IUploadProgress progress)
{
    if (progress.Exception != null)
    {
        Console.Error.WriteLine($"Upload Exception: {progress.Exception}");
     }

    Console.WriteLine($"Upload Status: {progress.Status}, Bytes sent: {progress.BytesSent}");
 }

And get this output

Upload Status: Starting, Bytes sent: 0
Upload Status: Uploading, Bytes sent: 10485760
Upload Status: Uploading, Bytes sent: 20971520
Upload Status: Uploading, Bytes sent: 31457280
Upload Status: Uploading, Bytes sent: 41943040
Upload Status: Uploading, Bytes sent: 52428800
Upload Status: Uploading, Bytes sent: 62914560
Upload Status: Uploading, Bytes sent: 73400320
Upload Status: Uploading, Bytes sent: 83886080
Upload Status: Uploading, Bytes sent: 94371840
Upload Status: Uploading, Bytes sent: 104857600
Upload Status: Uploading, Bytes sent: 115343360
Upload Status: Uploading, Bytes sent: 125829120
Upload Status: Uploading, Bytes sent: 136314880
Upload Status: Uploading, Bytes sent: 146800640
Upload Exception: System.Threading.Tasks.TaskCanceledException: The operation was canceled. ---> System.IO.IOException: Unable to read data from the transport connection: Operation canceled. ---> System.Net.Sockets.SocketException: Operation canceled
   --- End of inner exception stack trace ---
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error)
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.GetResult(Int16 token)
   at System.Net.Security.SslStreamInternal.<FillBufferAsync>g__InternalFillBufferAsync|38_0[TReadAdapter](TReadAdapter adap, ValueTask`1 task, Int32 min, Int32 initial)
   at System.Net.Security.SslStreamInternal.ReadAsyncInternal[TReadAdapter](TReadAdapter adapter, Memory`1 buffer)
   at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---
   at Google.Apis.Http.ConfigurableMessageHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) in C:\Apiary\2019-06-11.08-15-36\Src\Support\Google.Apis.Core\Http\ConfigurableMessageHandler.cs:line 494
   at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
   at Google.Apis.Upload.ResumableUpload.SendNextChunkAsync(Stream stream, CancellationToken cancellationToken) in C:\Apiary\2019-06-11.08-15-36\Src\Support\Google.Apis\Upload\ResumableUpload.cs:line 649
   at Google.Apis.Upload.ResumableUpload.UploadCoreAsync(CancellationToken cancellationToken) in C:\Apiary\2019-06-11.08-15-36\Src\Support\Google.Apis\Upload\ResumableUpload.cs:line 576
Upload Status: Failed, Bytes sent: 146800640

I think exception thrown always on the last chunk. After “Bytes sent: 146800640” in my case Size of my *.aab file is 156615227 bytes.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
nognomarcommented, Jul 3, 2019

Oh my bad. Increasing service.HttpClient.Timeout helped me.

0reactions
Thainacommented, May 26, 2022

I see, thank you very much

Read more comments on GitHub >

github_iconTop Results From Across the Web

Uploading Android App Bundle to Google Play Console
Try removing everything about the new app from console, then start by generating a new key and rebuilding the app with the new...
Read more >
About Android App Bundles
An Android App Bundle is a publishing format that includes all your app's compiled code and resources, and defers APK generation and signing...
Read more >
Publishing AAB fails because app signing isn't enabled
You must enroll into app signing by Google Play to upload an Android App Bundle. This error appears when you try to publish...
Read more >
Hi , i'm getting this error "This release does not add or ...
It sounds like the bundle is not getting added to the release. You said in your first post that the APK or bundle...
Read more >
Android App Bundle, how to upload game larger than 100 mb
I'm a bit stuck uploading my app to the store. I tried the App Bundles but my app exceeds the limit of mb...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found