2009-10-22 36 views
12

Scusate se è un po 'lungo ma ho pensato meglio di postare più di meno.Una connessione stabilita è stata interrotta dal software nel computer host

Questo è anche il mio primo post qui, quindi per favore perdonare.

Ho cercato di capire questo per un po 'di tempo. e senza alcun risultato, sperando che là fuori ci sia un genio che l'ha già incontrato.

Questo è un problema intermittente ed è stato difficile da riprodurre. Il codice che sto facendo funzionare semplicemente chiama un servizio Web La chiamata del servizio Web è in un ciclo (così potremmo fare questo molto, 1500 volte o più)

Ecco il codice che causa l'errore:

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(); 
    } 
} 

Ecco l'errore che a volte succede:

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() 

Mi dispiace che era un sacco di codice per leggere attraverso.
Questo succede circa 30 volte su circa 1700

+0

Questo errore è lato client o lato server? – Zote

+0

Lato client, ma questo viene generato dal servizio web – TheCodeFool

risposta

8

Probabilmente stai colpendo un timeout. Prima di tutto, riattiva il keepalive. In secondo luogo, controlla i timestamp sulla richiesta e rispondi. Se esiste un firewall tra il mittente e il destinatario, assicurarsi che non stia chiudendo la connessione a causa del timeout di inattività. Ho avuto entrambi questi problemi in passato, sebbene con la programmazione generica del socket, non con quella di DB.

+0

Faremo grazie per l'input, ho avuto il keep alive impostato sul valore predefinito di true, ma ho letto un post sul loro spegnimento, cercherò di esaminare il timeout di the firewall Grazie – TheCodeFool

Problemi correlati