Request hangs after RefreshToken expires JsonHttpClient ServiceStack

若如初见. 提交于 2021-01-28 04:07:25

问题


I'm using ServiceStack JsonHttpClient client (5.9.0) in my Xamarin.Forms mobile app.

Client is set like this:

client = new JsonHttpClient(App.BaseEndpoint)
{
   RefreshToken = RefreshToken,
};

var httpClient = client.GetHttpClient();
httpClient.Timeout = new TimeSpan(0, timeout, 0);

Refreshing of Bearer token works perfect, but after Refresh Token expires request just hangs with no response and without any exception.

here is request example:

public async Task GetAsync(string uri)
{
   try
   {
      var response = await client.GetAsync<string>(uri);
   }
   catch (RefreshTokenException ex)
   {
      throw new SessionExpiredException(AppResources.Error_SessionExpired);
   }
 }

If I use JsonServiceClient instead - after expiration of RefreshToken I'm getting RefreshTokenException as expected

Maybe someone have some fix or workaround for this. Thanks


回答1:


I've rewritten the JsonHttpClient manual Task continuations to use async/await in this commit which should use a better tested code path in Xamarin.

This change is available from the latest ServiceStack v5.9.1 that's now available on MyGet.

If it's still an issue you can try configuring JsonHttpClient to use the Xamarin's native HttpClient implementations for iOS using NSUrlSessionHandler and for Android using AndroidClientHandler.



来源:https://stackoverflow.com/questions/62523319/request-hangs-after-refreshtoken-expires-jsonhttpclient-servicestack

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!