我在下面复制了异常。我已经通过VPN连接了Android设备,如果VPN连接失败,则FlurlHttp调用给出了未处理的异常。我正在Xamarin.Android上开发应用程序。如果设备通过VPN连接,则可以正常工作。请有人提供一些解决方案,如何处理。
如何使用Flurl Http调用获取响应StatusCode(200)?
Flurl.Http.FlurlHttpException: Request to http://192.168.110.60/TestServices/MyCall.aspx?method=Test&username=abc&password=abc failed. A task was canceled. ---> System.Threading.Tasks.TaskCanceledException: A task was canceled.
--- End of inner exception stack trace ---
at Flurl.Http.Configuration.FlurlMessageHandler+<SendAsync>d__1.MoveNext () [0x00000] in C:\projects\flurl\src\Flurl.Http.Shared\Testing\HttpCallAssertion.cs:192
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00042] in <1c7d529d87ec4bdcbde02e9494f3b5ae>:0
at Microsoft.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess (System.Threading.Tasks.Task task) [0x0001c] in <1c7d529d87ec4bdcbde02e9494f3b5ae>:0
at Microsoft.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00009] in <1c7d529d87ec4bdcbde02e9494f3b5ae>:0
at Microsoft.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <1c7d529d87ec4bdcbde02e9494f3b5ae>:0
at Flurl.Http.HttpResponseMessageExtensions+<ReceiveString>d__3.MoveNext () [0x00000] in C:\projects\flurl\src\Flurl.Http.Shared\Testing\HttpCallAssertion.cs:150
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <abd9ee18f6114b4cae6c0d74712f64b5>:0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <abd9ee18f6114b4cae6c0d74712f64b5>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <abd9ee18f6114b4cae6c0d74712f64b5>:0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <abd9ee18f6114b4cae6c0d74712f64b5>:0
at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in <abd9ee18f6114b4cae6c0d74712f64b5>:0
at PCLTest.APIRepository.APIRepo+<ValidateUrl>d__0.MoveNext () [0x0004f] in C:\D-Drive\branches\PCLTest\APIRepository\APIRepo.cs:20
An unhandled exception occured.
最佳答案
请求未完成。 TaskCanceledException
表示它已被明确取消(通过CancelationToken
),或者更有可能发生了超时。它会在抛出异常之前旋转一段时间吗?更有可能是超时。 Flurl的默认超时为100秒,但是您可以将其configure设置为其他超时。
另外,如果可能的话,我强烈建议您upgrade Flurl.Http。您正在使用非常旧的版本。