Hi Guys,
I am working on sync file from box to another source. Almost 3 weeks ago, we found there are lots of download file API timeout issue was occured in our production. I am try to print the error log.
~~~ json
"@t": "2022-03-18T08:37:13.1328496Z",
"@mt": "ExternalContentSync BoxApiWrapper ExecuteBasicRequest exception {@Detail}",
"@l": "Error",
"Detail": {
"AbsoluteUri": "
https://api.box.com/2.0/files/932716620970/content?Range=bytes=0-62272"
,
"Message": "A task was canceled.",
"StackTrace": " at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)\r\n at System.Net.Http.HttpClient.<FinishSendAsyncUnbuffered>d__59.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at Box.V2.Request.HttpRequestHandler.<ExecuteAsync>d__2`1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)\r\n at Box.V2.Services.BoxService.<ToResponseAsync>d__4`1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)\r\n at Nuage.Common.External.ExternalContentV3.ApiClients.BoxApiClient.ExecuteRequest[T](IBoxRequest request) in c:\\users\\seismic\\workspace\\ines_cap-library_release_release\\Common.External\\ExternalContentV3\\ApiClients\\Box\\BoxApiClient.cs:line 116\r\n at Nuage.Common.External.ExternalContentV3.Wrappers.BoxApiWrapper.ExecuteBasicRequest[T](IBoxRequest request) in c:\\users\\seismic\\workspace\\ines_cap-library_release_release\\Common.External\\ExternalContentV3\\Wrappers\\BoxApiWrapper.cs:line 363"
}
~~~
this is our code to use the Box sdk
~~~ C#
private Stream BoxExecuteBasicRequest(string fileId, long startByte, long endByte)
{
Stopwatch stopWatch = Stopwatch.StartNew();
var url = string.Format("https://api.box.com/2.0/files/{0}/content?Range=bytes={1}-{2}", fileId, startByte, endByte);
IRequestHandler handler = new HttpRequestHandler();
var service = new BoxService(new HttpRequestHandler());
try
{
BoxRequest boxrequest = new BoxRequest(new Uri(url));
boxrequest.Timeout = TimeSpan.FromSeconds(1200);
var responseResult = service.ToResponseAsync<Stream>(boxrequest).GetAwaiter().GetResult();
if (responseResult.Status == ResponseStatus.Success)
{
return responseResult.ResponseObject;
}
else
{
return this.ResponseErrorHandler<string>(boxrequest, responseResult);
}
}
catch (Exception ex)
{
stopWatch.Stop();
LogFactory.GetLogger(LogType.ExternalContent).Error(
"ExternalContentSync BoxApiWrapper ExecuteBasicRequest exception {@Detail}, Request duration {requestDuration} ms", new
{
url,
ex.Message,
ex.StackTrace
}, stopWatch.ElapsedMilliseconds.ToString());
throw;
}
}
~~~
We were change the timeout to 1200 seconds in BoxRequest object, but we still occured the timeout issue, and request was pended 1200 seconds.
~~~ json
"@t": "2022-03-18T12:45:55.9677376Z",
"@mt": "ExternalContentSync BoxApiWrapper ExecuteBasicRequest exception {@Detail}, Request duration {requestDuration} ms",
"@l": "Error",
"Detail": {
"AbsoluteUri": "
https://api.box.com/2.0/files/932718617698/content?Range=bytes=0-26969"
,
"Message": "A task was canceled.",
"StackTrace": " at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)\r\n at System.Net.Http.HttpClient.<FinishSendAsyncUnbuffered>d__59.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)\r\n at Box.V2.Request.HttpRequestHandler.<ExecuteAsync>d__2`1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)\r\n at Box.V2.Services.BoxService.<ToResponseAsync>d__4`1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)\r\n at Nuage.Common.External.ExternalContentV3.ApiClients.BoxApiClient.ExecuteRequest[T](IBoxRequest request) in c:\\users\\seismic\\workspace\\ines_cap-library_release_release\\Common.External\\ExternalContentV3\\ApiClients\\Box\\BoxApiClient.cs:line 117\r\n at Nuage.Common.External.ExternalContentV3.Wrappers.BoxApiWrapper.ExecuteBasicRequest[T](IBoxRequest request) in c:\\users\\seismic\\workspace\\ines_cap-library_release_release\\Common.External\\ExternalContentV3\\Wrappers\\BoxApiWrapper.cs:line 366"
},
"requestDuration": "1200010",
~~~
Could you please help us?
Hey Paul,
There couple be lots of reasons for this...
Do you have the client id for the Box application you created in the developer console? The enterprise ID of your instance would be helpful too.
Also. To confirm - you are using this sdk?