I am using HttpClient (System.Net.Http) to send a GET request and I occasionally get the following exception:
Unable to read data from the transport connection. The connection was closed before all data could be read. Expected 894 bytes, read 0 bytes.
The instance of HttpClient that I am using is static, as Microsoft recommends, and I set the Connection header to "keep-alive". I am setting the Authorization header per request and sending the request using the following code:
var request = new HttpRequestMessage(HttpMethod.Get, requestUri);
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", _authorizationHeader);
var response = await HttpClient.SendAsync(request);
The exception is thrown on the last line in the snippet. Can someone help me figure out what would be causing this exception to be thrown?