Am getting this error when i deploy my app to production server while in my local machine its working well
System.Net.WebException: The underlying connection was closed: An unexpected er or occurred on a send. ---> System.IO.IOException: Authentication failed becaus the remote party has closed the transport stream. at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readByte , AsyncProtocolRequest asyncRequest) at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtoco Request asyncRequest) at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolTok n message, AsyncProtocolRequest asyncRequest) at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, syncProtocolRequest asyncRequest) at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, at zz.Program.Main(String[] args)
This part of the code
string MsgType = "cmpi_authenticate";
string Version = "1.7";
XElement elem = new XElement("CardinalMPI",
new XElement("MsgType", MsgType),
new XElement("Version", Version),
new XElement("ProcessorId", ProcessorId),
new XElement("MerchantId", MerchantId),
new XElement("TransactionPwd", TransactionPwd),
new XElement("TransactionType", TransactionType),
new XElement("TransactionId", TransactionId),
new XElement("PAResPayload", PAResPayload)
);
StringBuilder postData = new StringBuilder();
postData.Append("cmpi_msg=" + HttpUtility.UrlEncode(elem.ToString()));
ASCIIEncoding encoding = new ASCIIEncoding();
byte[] data = encoding.GetBytes(postData.ToString());
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "POST";
request.Timeout = 30 * 1000;
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = data.Length;
Stream newStream = request.GetRequestStream();
newStream.Write(data, 0, data.Length);
//newStream.Flush();
//newStream.Close();
//request.KeepAlive = false;
string resText = "";
//ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
//**this is the point of failure**
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
Encoding enc = System.Text.Encoding.GetEncoding(1252);
using (StreamReader rs = new StreamReader(response.GetResponseStream(), enc))
{
resText = rs.ReadToEnd();
//Console.WriteLine("RES:" + resText);
}
}