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

Downloading large file getting this error [Caused by: okhttp3.internal.http2.StreamResetException: stream was reset: CANCEL] #2268

Closed
ihudedi opened this issue Jan 8, 2025 · 6 comments
Assignees
Labels
Needs: Attention 👋 type:question An issue that's a question

Comments

@ihudedi
Copy link

ihudedi commented Jan 8, 2025

Describe the bug

Hi,
When downlaoding large file via (buffer can be 512KB,4MB,8MB and it's always fail)

try(InputStream inputStream = graphServiceClient.drives().byDriveId(driveId).items().byDriveItemId(getDriveItemIdFromRootPath(filePath)).content().get()){
byte[] buf = new byte[spoFileCopy.getCloudPartSizeWhenDownloadingToLocal()];
int bytesRead;
while ((bytesRead = srcInputStream.read(buf)) != -1) {
spoFileCopy.getOutputStream().write(buf, 0, bytesRead);
}
} catch (Exception e) {
logger.error(String.format("Error in SPOWrapper::downloadFileToLocalFileSystem: filePath= '%s' %s", originalFilePath, e.getMessage()), e);
throw e;
} finally {
logger.debug(String.format("End SPOWrapper::downloadFileToLocalFileSystem: filePath= '%s' ", originalFilePath));
}

I am getting this error after ~90 seconds of downlaoding:
java.io.InterruptedIOException: timeout
at okhttp3.internal.connection.RealCall.timeoutExit(RealCall.kt:398) ~[okhttp-4.12.0.jar!/:?]
at okhttp3.internal.connection.RealCall.callDone(RealCall.kt:360) ~[okhttp-4.12.0.jar!/:?]
at okhttp3.internal.connection.RealCall.messageDone$okhttp(RealCall.kt:309) ~[okhttp-4.12.0.jar!/:?]
at okhttp3.internal.connection.Exchange.bodyComplete(Exchange.kt:198) ~[okhttp-4.12.0.jar!/:?]
at okhttp3.internal.connection.Exchange$ResponseBodySource.complete(Exchange.kt:329) ~[okhttp-4.12.0.jar!/:?]
at okhttp3.internal.connection.Exchange$ResponseBodySource.read(Exchange.kt:305) ~[okhttp-4.12.0.jar!/:?]
at okio.RealBufferedSource$inputStream$1.read(RealBufferedSource.kt:162) ~[okio-jvm-3.9.1.jar!/:?]
at java.base/java.io.InputStream.read(Unknown Source) ~[?:?]
at com.bmc.cm.aft.client.wrapper.SPOWrapper.downloadFileToLocalFileSystem(SPOWrapper.java:919) [classes!/:?]
at com.bmc.cm.aft.client.SPODownloadToLocalFileCopy.downloadFileToLocalFileSystem(SPODownloadToLocalFileCopy.java:77) [classes!/:?]
at com.bmc.cm.aft.client.CloudFileCopy.copyFile(CloudFileCopy.java:172) [classes!/:?]
at com.bmc.cm.aft.client.FileCopy.transfer(FileCopy.java:1682) [classes!/:?]
at com.bmc.cm.aft.client.FileCopy.run(FileCopy.java:1513) [classes!/:?]
at com.bmc.cm.aft.client.FTCTransfer.copySingleFile(FTCTransfer.java:925) [classes!/:?]
at com.bmc.cm.aft.client.FTCTransfer.copy(FTCTransfer.java:802) [classes!/:?]
at com.bmc.cm.aft.client.FTCTransfer.runCopy(FTCTransfer.java:383) [classes!/:?]
at com.bmc.cm.aft.client.FTCTransfer.run(FTCTransfer.java:312) [classes!/:?]
at com.bmc.cm.aft.client.SubtaskRunner.run(SubtaskRunner.java:628) [classes!/:?]
at com.bmc.cm.aft.client.FTCHandler.runSubTasks(FTCHandler.java:388) [classes!/:?]
at com.bmc.cm.aft.client.FTCHandler.runJob(FTCHandler.java:219) [classes!/:?]
at com.bmc.cm.aft.jobmanagement.JobObjectImpl$JobRunnerThread.run(JobObjectImpl.java:401) [classes!/:?]
Caused by: okhttp3.internal.http2.StreamResetException: stream was reset: CANCEL
at okhttp3.internal.http2.Http2Stream$FramingSource.read(Http2Stream.kt:355) ~[okhttp-4.12.0.jar!/:?]
at okhttp3.internal.connection.Exchange$ResponseBodySource.read(Exchange.kt:281) ~[okhttp-4.12.0.jar!/:?]
... 15 more

I don't have timeout - I see all to some minutes.
When the file is large and it takes time to download this error is arised.
Not always but reproduce with 1GB
Thanks,
Itay

Expected behavior

File should download completed.

How to reproduce

See all code above

SDK Version

6.25.1

Latest version known to work for scenario above?

No response

Known Workarounds

No response

Debug output

Click to expand log ```
</details>


### Configuration

_No response_

### Other information

_No response_
@ihudedi ihudedi added status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience labels Jan 8, 2025
@Ndiritu
Copy link
Contributor

Ndiritu commented Jan 13, 2025

@ihudedi the SDK initialises the OkHttpClient with a default read timeout of 100s. It seems likely that that's why this error occurs.

To customize the timeouts & the HTTP client in general:

OkHttpClient client = GraphClientFactory.create().readTimeout(Duration.ofSeconds(180)).build();
GraphServiceClient graphClient = new GraphServiceClient(
    new AzureIdentityAuthenticationProvider(credential, new String[] {}, ".default"),
    client
);

let me know if this works/you have any further questions.

@Ndiritu Ndiritu added type:question An issue that's a question status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close and removed status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience labels Jan 13, 2025
@Ndiritu Ndiritu self-assigned this Jan 13, 2025
@ihudedi
Copy link
Author

ihudedi commented Jan 13, 2025

Hi @Ndiritu
The default value for readTimeout is 10 seconds. (OkHttpClient.kt)
Anyway I increased the time with no effect.
I am using the scope as "https://graph.microsoft.com/.default".
Same issue.
Thanks,
Itay

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: Attention 👋 and removed status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close labels Jan 13, 2025
@ihudedi
Copy link
Author

ihudedi commented Jan 15, 2025

Hi @Ndiritu
Any updates?
Thanks,
Itay

@Ndiritu
Copy link
Contributor

Ndiritu commented Jan 15, 2025

@ihudedi my apologies, we should have tried to increase the callTimeout instead.
so:

OkHttpClient client = GraphClientFactory.create().callTimeout(Duration.ofSeconds(180)).build();
GraphServiceClient graphClient = new GraphServiceClient(
    new AzureIdentityAuthenticationProvider(credential, new String[] {}, ".default"),
    client
);

The default value for readTimeout is 10 seconds. (OkHttpClient.kt)

The SDK overrides these defaults to 100 seconds for the writeTimeout, readTimeout and callTimeout

@Ndiritu Ndiritu added status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close and removed Needs: Attention 👋 labels Jan 15, 2025
@ihudedi
Copy link
Author

ihudedi commented Jan 15, 2025

Hi @Ndiritu
I didn't have this issue when using azure blob.
So should I set the call Timeout to 10 minutes when downloading large file?
I didn't see the sdk set this value.
Could you please point me where because I will set this both in azure and graph api
Thanks,
Itay

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: Attention 👋 and removed status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close labels Jan 15, 2025
@ihudedi
Copy link
Author

ihudedi commented Jan 21, 2025

Hi @Ndiritu
Issue resolved by changing callTimeout.
Thanks,
Itay

@Ndiritu Ndiritu closed this as completed Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs: Attention 👋 type:question An issue that's a question
Projects
None yet
Development

No branches or pull requests

2 participants