Open valutcizen opened 4 years ago
Could you please create a small test app to reproduce the issue? Parallel read shoudl not happen here, so no race condition..unless you are doing something strange.
The problem with small test app is that there is no problems with open street maps since 18th September, and this issue I have only on these servers, so now it is not possible to reproduce this issue.
But what did you wrote to the TWP event handler? It should not be called parallel.
private async Task Proxy_BeforeResponse(object sender, SessionEventArgs e)
{
try
{
if (e.Exception != null || e.HttpClient.Response.StatusCode != 200)
{
await TryRetringAsync(e);
}
else
{
Task bodyTask = e.GetResponseBody();
if (!bodyTask.Wait(timeout))
await TryRetringAsync(e);
}
}
catch (Exception ex)
{
LogToFile(ex.ToString());
}
}
Where TryRetryingAsync is method that download body by HttpClient and changes response to new body.
Sometimes working with Open Streets Maps (OSM) on specific time (starts about 15:00 UTC+2) there is response that cause
bufferLength
is less than 0! Everywhere in source it is impossible until it is race condition.My app: proxy that fixes OSM issue with endless connection. I wait for body 30 seconds and if this is not appears I ask few times again by HttpClient.
bytesRead <= 0
is changed by me to prevent endless loop.