2

我已经复制了下面的异常。我已经通过 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.
4

1 回答 1

1

请求未完成。TaskCanceledException意味着它被明确取消(通过 a CancelationToken),或者更有可能发生了超时。在抛出异常之前它会旋转一段时间吗?更有可能是超时。Flurl 的默认超时时间是 100 秒,但您可以将其配置为其他值。

另外,如果可能,我强烈建议您升级Flurl.Http。您使用的是非常旧的版本。

于 2018-05-23T13:59:27.883 回答