I have the following code to add logs to log analytics:
private static readonly HttpClient httpClient = MakeClient();
private static HttpClient MakeClient()
{
var client = new HttpClient();
client.DefaultRequestHeaders.Add("Log-Type", "ApplicationLog");
return client;
}
On running this, I get the below exception:
The request was canceled due to the configured HttpClient.Timeout of 100 seconds elapsing. The operation was canceled. The operation was canceled. The read operation failed, see inner exception. Cannot access a disposed object. Object name: 'SslStream'.
on this line:
var response = await httpClient.SendAsync(
CreateRequest(HttpMethod.Post, url, scheme, parameter, dateString, serializedMessage, contentType));
What am I missing?
HttpClient has a default timeout of 100 sec. You can set the value based on your requirements.
httpClient.Timeout = TimeSpan.FromMinutes(10);
For refrence
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With