ShareFile-NET
ShareFile-NET copied to clipboard
Constantly getting I\O errors trying to Upload to ShareFile with the API
I get errors like below all the time when I try to upload with the ShareFile-NET SDK.
Tons of I\O errors and I don't know why. My upload code is as simple as this:
_logger.LogDebug("Processing FILE: [{0}]", filepath);
await using var file = File.Open(filepath, FileMode.Open);
var uploadRequest = new UploadSpecificationRequest
{
FileName = file.Name,
FileSize = file.Length,
Details = "MISO Automated Transfer",
Parent = parentFolder.url
};
var uploader = sfClient.GetAsyncFileUploader(uploadRequest, file);
uploader.OnTransferProgress += UploaderOnTransferProgress;
var uploadResponse = await uploader.UploadAsync();
System.Threading.Tasks.TaskCanceledException: The request was canceled due to the configured HttpClient.Timeout of 100 seconds elapsing. ---> System.TimeoutException: The operation was canceled. ---> System.Threading.Tasks.TaskCanceledException: The operation was canceled. ---> System.IO.IOException: Unable to read data from the transport connection: The I/O operation has been aborted because of either a thread exit or an application request.. ---> System.Net.Sockets.SocketException (995): The I/O operation has been aborted because of either a thread exit or an application request. --- End of inner exception stack trace --- at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken) at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.GetResult(Int16 token) at System.Net.Security.SslStream.ReadAsyncInternal[TIOAdapter](TIOAdapter adapter, Memory`1 buffer) at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) --- End of inner exception stack trace --- at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
How big are the files? Can you try increasing the timeout?
var config = ShareFile.Api.Client.Configuration.Default();
config.HttpTimeout = 200 * 1000 // value is in ms
var sfClient = new SharefileClient(baseUrl, config);
Yeah some of them are like 20 megabytes and more. I think I will try this.
But, sometimes it fails on even small files and I see things like this:
[01:26:15 DBG] :-: Processing FILE: [D:\temp\RptPub\ORCA\DA_NSI.csv] :-: MISO.CmdCore.Commands.OutgoingCommand.#
[01:27:17 ERR] :-: Command Run Error :-: MISO.CmdCore.Commands.OutgoingCommand.#
ShareFile.Api.Client.Exceptions.ODataException
at ShareFile.Api.Client.Requests.Providers.AsyncRequestProvider.HandleNonSuccess(HttpResponseMessage responseMessage, Int32 retryCount, Type expectedType)
at ShareFile.Api.Client.Requests.Providers.AsyncRequestProvider.HandleTypedResponse[T](HttpResponseMessage httpResponseMessage, ApiRequest request, Int32 retryCount, Boolean tryResolveUnauthorizedChallenge)
at ShareFile.Api.Client.Requests.Providers.AsyncRequestProvider.ExecuteAsync[T](IQuery1 query, CancellationToken token) at ShareFile.Api.Client.Transfers.Uploaders.AsyncUploaderBase.CreateUpload(CancellationToken cancellationToken) at ShareFile.Api.Client.Transfers.Uploaders.AsyncStandardFileUploader.PrepareAsync(CancellationToken cancellationToken) at ShareFile.Api.Client.Transfers.Uploaders.AsyncUploaderBase.UploadAsync(Dictionary2 transferMetadata, CancellationToken cancellationToken)