pnpcore
pnpcore copied to clipboard
Downloading large files 2 issues
The default HTTP timeout is 100 seconds,
-
If the timeout is reached while loading the file, no exception or error will be thrown. Simply downloading the file will remain incomplete or defective. Expected behavior: When the timeout is reached, an exception should be thrown.
-
If you use GetPnPContextAsync, then the timeout cannot be set or inheritance from ClientRuntimeContext.RequestTimeout does not work. Expected behavior: Timeout must be set by their ClientRuntimeContext.RequestTimeout or be able to configure.
example: I am using pnp in .net framework 4.8 project with classic Microsoft.SharePoint.Client.ClientContext only in the download location
var clientContext = //crete classic client context
clientContext.RequestTimeout = 1800000; //30 minutes
using (var pnpCoreContext = await PnPCoreSdk.Instance.GetPnPContextAsync(clientContext))
{
IFile targetFile = await pnpCoreContext.Web.GetFileByServerRelativeUrlAsync(fileRef);
var stream = await targetFile.GetContentAsync(true);
//stream read by chunk code
}
@alexeygritsenko : PnP Core SDK does have an option to set the timeout (see https://pnp.github.io/pnpcore/using-the-sdk/basics-settings.html#settings-overview and https://pnp.github.io/pnpcore/using-the-sdk/files-large.html). It's however not possible to set this at the CSOM ClientContext
and then use it in PnP Core SDK. If you directly instantiate the PnP Context and use the configuration setting, then things will work.
This however raises an interesting point on how to plug-in configuration settings when PnP Core SDK is instantiated via PnP Framework, guess some updates are needed in https://github.com/pnp/pnpframework/blob/dev/src/lib/PnP.Framework/PnPCoreSdk.cs#L83-L129
This however raises an interesting point on how to plug-in configuration settings when PnP Core SDK is instantiated via PnP Framework, guess some updates are needed in https://github.com/pnp/pnpframework/blob/dev/src/lib/PnP.Framework/PnPCoreSdk.cs#L83-L129 👍
And as for point 1 (timeout triggering), it looks like this behavior HttpClient. When I download a file and read it in parts of 8 MB (buffer), even for a long time (7 minutes), there are no connection problems (with a 100 sec default timeout).
@alexeygritsenko : so you're unblocked at the moment?
@alexeygritsenko : tracking the need to set configuration from PnP Framework in #987. Closing this issue now.