My code making https request. This is my code
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(UploadUrl);
request.Method = "POST";
request.KeepAlive = false;
request.Credentials = new NetworkCredential(userid, testpwd);
postData = "<root></root>";
request.ContentType = "application/x-www-form-urlencoded";
byte[] postDataBytes = Encoding.UTF8.GetBytes(postData);
request.ContentLength = postDataBytes.Length;
Stream requestStream = request.GetRequestStream();
requestStream.Write(postDataBytes, 0, postDataBytes.Length);
requestStream.Close();
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
StreamReader responseReader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
var result = responseReader.ReadToEnd();
responseReader.Close();
Console.WriteLine(result);
}
This code was running good but all of a sudden throwing following exception
System.Net.WebException
The exception message is: The underlying connection was closed: An unexpected error occurred on a send.
Stack Trace: at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context) at System.Net.HttpWebRequest.GetRequestStream() at CustomerProcessor.Delivery.Deliver(String content, Int32 productCategory, String identifier, String xsltFile)
The Exception has an inner exception: An Exception occurred: System.IO.IOException The exception message is: Received an unexpected EOF or 0 bytes from the transport stream.
Stack Trace: at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count) at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest) at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest) at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest) at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest) at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest) at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult) at System.Net.TlsStream.CallProcessAuthentication(Object state) at System.Threading.ExecutionContext.runTryCode(Object userData) at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result)
at System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size) at System.Net.PooledStream.Write(Byte[] buffer, Int32 offset, Int32 size) at System.Net.ConnectStream.WriteHeaders(Boolean async)
Is there any chance to see what could be the cause of this issue?