问题
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