从传输流中收到意外的EOF或0字节

时间:2015-06-03 12:41:05

标签: c# asp.net https

我使用asp.net 3.5从一个窗口应用程序调用PayTM API。 这是我的主叫代码

HttpWebRequest myWebRequest = null;
string postString = ReturnRequestUrl();
Uri DemorUri = new Uri(postString);
myWebRequest = (HttpWebRequest)WebRequest.Create(DemorUri); 
myWebRequest.ProtocolVersion = HttpVersion.Version10;
myWebRequest.Method = "POST";
myWebRequest.ContentType = "application/x-www-form-urlencoded";
myWebRequest.Timeout = 180000;

StreamReader responseReader = new StreamReader(myWebRequest.GetResponse().GetResponseStream());
WebResponse myWebResponse = myWebRequest.GetResponse();
Stream ReceiveStream = myWebResponse.GetResponseStream();
Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
StreamReader readStream = new StreamReader(ReceiveStream, encode);
string response = readStream.ReadToEnd();

但我收到了这个错误

    See the end of this message for details on invoking 
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. ---> System.IO.IOException: Received an unexpected EOF or 0 bytes from the transport stream.
   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)
   --- End of inner exception stack trace ---
   at System.Net.HttpWebRequest.GetResponse()

仅在Window XP PC上出现此错误。 我已经尝试了

ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;

在致电该请求之前。

请帮忙

0 个答案:

没有答案