Query is made from a httpclient hosted in WPF control to azure server and azure server sends the results back to WPF control. On Windows 7 Os an exception is thrown when the postasync is called. Please help me how to resolve the below exception.
Note : This works fine on Windows 10 client machine
var httpContent = new StringContent(value, Encoding.UTF8, "application/json");
var queryUri = new Uri(httpClient.BaseAddress, "content/resultvalue");
try {
var response = await httpClient.PostAsync(queryUri, httpContent);
response.EnsureSuccessStatusCode();
var resultJson = await response.Content.ReadAsStringAsync();
var result = JsonConvert.DeserializeObject<Result>(resultJson);
} catch (Exception e) {
//report the exception to the user
}
Exception Messages: WebException : The underlying connection was closed: An unexpected error occurred on a send. IOException : Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. SocketException : An existing connection was forcibly closed by the remote host
Type : System.Net.WebException, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 Message : The underlying connection was closed: An unexpected error occurred on a send. Source : System Status : SendFailure Response : TargetSite : System.IO.Stream EndGetRequestStream(System.IAsyncResult, System.Net.TransportContext ByRef) Stack Trace : at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult, TransportContext& context) at System.Net.Http.HttpClientHandler.GetRequestStreamCallback(IAsyncResult ar) Inner Exception --------------- Type : System.IO.IOException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 Message : Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. Source : System TargetSite : Void EndWrite(System.IAsyncResult) Stack Trace : at System.Net.TlsStream.EndWrite(IAsyncResult asyncResult) at System.Net.PooledStream.EndWrite(IAsyncResult asyncResult) at System.Net.ConnectStream.WriteHeadersCallback(IAsyncResult ar) Inner Exception --------------- Type : System.Net.Sockets.SocketException, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 Message : An existing connection was forcibly closed by the remote host Source : System ErrorCode : 10054 SocketErrorCode: ConnectionReset NativeErrorCode: 10054 TargetSite : Int32 EndReceive(System.IAsyncResult) Stack Trace : at System.Net.Sockets.Socket.EndReceive(IAsyncResult asyncResult) at System.Net.Sockets.NetworkStream.EndRead(IAsyncResult asyncResult)