2009-10-22 55 views
12

Xin lỗi nếu điều này hơi dài nhưng tôi nghĩ tốt hơn nên đăng nhiều hơn ít hơn.Kết nối đã được thiết lập đã bị hủy bỏ bởi phần mềm trong máy chủ của bạn

Đây cũng là bài đăng đầu tiên của tôi ở đây, vì vậy vui lòng tha thứ.

Tôi đã cố gắng tìm ra điều này một thời gian. và vô ích, hy vọng có một thiên tài ngoài kia đã từng gặp điều này trước đây.

Đây là vấn đề liên tục và khó tái tạo. Mã mà tôi đang chạy chỉ gọi một dịch vụ web Cuộc gọi dịch vụ web đang trong vòng lặp (vì vậy chúng tôi có thể thực hiện điều này rất nhiều, từ 1500 lần trở lên)

Đây là mã gây ra lỗi:

HttpWebRequest groupRequest = null; 
WebResponse groupResponse = null;    
try 
{  
    XmlDocument doc = new XmlDocument(); 
    groupRequest = (HttpWebRequest)HttpWebRequest.Create(String.Format(Server.HtmlDecode(Util.GetConfigValue("ImpersonatedSearch.GroupLookupUrl")),userIntranetID)); 
    groupRequest.Proxy = null; 
    groupRequest.KeepAlive = false; 
    groupResponse = groupRequest.GetResponse(); 
    doc.Load(groupResponse.GetResponseStream()); 
    foreach (XmlElement nameElement in doc.GetElementsByTagName(XML_GROUP_NAME)) 
    { 
     foreach (string domain in _groupDomains) 
     { 
      try 
      { 
       string group = new System.Security.Principal.NTAccount(domain, nameElement.InnerText).Translate(typeof(System.Security.Principal.SecurityIdentifier)).Value; 
       impersonationChain.Append(";").Append(group);        
       break; 
      } 
      catch{}       
     } // loop through    
    } 
} 
catch (Exception groupLookupException) 
{ 
    throw new ApplicationException(String.Format(@"Impersonated Search ERROR: Could not find groups for user<{0}\{1}>", userNTDomain, userIntranetID), groupLookupException); 
} 
finally 
{ 
    if (groupResponse != null) 
    { 
     groupResponse.Close(); 
    } 
} 

đây là lỗi điều đó xảy ra đôi khi:

Could not find groups for user<DOMAIN\auser> ---> System.IO.IOException: Unable to read 
data from the transport connection: An established connection was aborted by the 
software in your host machine. ---> System.Net.Sockets.SocketException: An established 
connection was aborted by the software in your host machine at 
System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags 
socketFlags) at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 
size) --- End of inner exception stack trace --- at System.Net.ConnectStream.Read(Byte[] 
buffer, Int32 offset, Int32 size) at System.Xml.XmlTextReaderImpl.ReadData() at 
System.Xml.XmlTextReaderImpl.ParseDocumentContent() at 
System.Xml.XmlLoader.LoadDocSequence 
(XmlDocument parentDoc) at System.Xml.XmlDocument.Load(XmlReader reader) at 
System.Xml.XmlDocument.Load(Stream inStream) at 
MyWebServices.ImpersonatedSearch.PerformQuery(QueryParameters parameters, 
String userIntranetID, String userNTDomain)--- End of inner exception stack trace 
---at MyWebServices.ImpersonatedSearch.PerformQuery(QueryParameters parameters, String userIntranetID, String userNTDomain) 
--- End of inner exception stack trace --- 
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, 
WebResponse response, Stream responseStream, Boolean asyncCall) 
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, 
Object[] parameters) at MyProgram. MyWebServices.ImpersonatedSearch.PerformQuery 
(QueryParameters parameters, String userIntranetID, String userNTDomain) 
at MyProgram.MyMethod() 

Xin lỗi đó là rất nhiều mã để đọc qua.
Điều này xảy ra khoảng 30 lần trong khoảng 1700

+0

Lỗi này là phía máy khách hoặc phía máy chủ? – Zote

+0

Phía khách hàng, nhưng điều này được đưa ra từ webservice – TheCodeFool

Trả lời

8

Có thể bạn đã hết thời gian chờ. Trước hết, hãy bật trở lại. Thứ hai, kiểm tra dấu thời gian trên yêu cầu và trả lời. Nếu có tường lửa giữa người gửi và người nhận, hãy đảm bảo rằng nó không đóng kết nối vì thời gian chờ không hoạt động. Tôi đã có cả hai vấn đề này trong quá khứ, mặc dù với lập trình socket chung, không phải công cụ DB.

+0

Sẽ làm ơn cảm ơn cho đầu vào, tôi đã giữ thiết lập còn sống về mặc định là true, nhưng đọc một bài đăng về việc tắt chúng đi, tôi sẽ cố gắng xem xét thời gian chờ của tường lửa Cảm ơn – TheCodeFool

Các vấn đề liên quan