我的代碼發出https請求。這是我的代碼通過https獲取EOF異常請致電
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);
}
此代碼是運行良好,但突然投擲以下異常
System.Net.WebException
異常消息是: 基礎連接已經關閉:發生意外的錯誤發送。
堆棧跟蹤: 在System.Net.HttpWebRequest.GetRequestStream(TransportContext &上下文) 在System.Net.HttpWebRequest.GetRequestStream() 在CustomerProcessor.Delivery.Deliver(字符串的內容,的Int32產品分類,字符串標識符,字符串xsltFile)
異常具有內異常:發生 異常: System.IO.IOException 異常消息爲: 從傳輸流接收到一個意想不到的EOF或0字節。
堆棧跟蹤: 在System.Net.FixedSizeReader.ReadPacket(字節[]緩衝液,的Int32偏移的Int32計數) 在System.Net.Security.SslState.StartReadFrame(字節[]緩衝液,的Int32的ReadBytes,AsyncProtocolRequest asyncRequest ) 在System.Net.Security.SslState.StartReceiveBlob(字節[]緩衝液,AsyncProtocolRequest asyncRequest) 在System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken消息,AsyncProtocolRequest asyncRequest) 在System.Net.Security.SslState.StartSendBlob (Byte [] incoming,Int32 count,AsyncProtocolRequest asyncRequest) at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst,Byte [] buffer,AsyncProtocolRequest asyncRequest) 在System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult) 在System.Net.TlsStream.CallProcessAuthentication(對象狀態) 在System.Threading.ExecutionContext.runTryCode(對象的UserData) 在System.Runtime.CompilerServices.RuntimeHelpers .ExecuteCodeWithGuaranteedCleanup(TryCode代碼,CleanupCode backoutCode,對象的UserData) 在System.Threading.ExecutionContext.RunInternal(的ExecutionContext的ExecutionContext,ContextCallback回調,對象狀態) 在System.Threading.ExecutionContext.Run(的ExecutionContext的ExecutionContext,ContextCallback回調,對象狀態)在System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult結果) 在System.Net.TlsStream.Write(Byte []緩衝區,Int32偏移量,Int32大小) 在System.Net.PooledStream.Write(字節[]緩衝區,Int32偏移量,Int32大小) 在System.Net.ConnectStream.WriteHeaders(布爾異步)
有沒有任何機會看到什麼可能是這個原因問題?
這只是保存了我的一天..顯然還有網站在那裏運行SSL2.0。 – Grubsnik 2012-10-24 13:47:50