0

J'ai un code complexe, dans une section j'envoie un webrequest de repos à un service Web et obtiens sa réponse pour le reste du travail, la réponse a la taille de variant, quelques fois son lourd, sur IIS Express sur VS il n'y a pas de problème mais quand il passe en live sur IIS il lance System.Net.WebException: l'opération a expiré. et ceci est le code que j'utilise:System.Net.WebException: l'opération a expiré

Dim req As HttpWebRequest = TryCast(WebRequest.Create("http://www.somedomain.com/service.svc"), HttpWebRequest) 
     Using TryCast(req, IDisposable) 
      req.Proxy = Nothing 
      req.ServicePoint.ConnectionLimit = 100 
      req.ServicePoint.MaxIdleTime = 3000000 
      req.Method = "POST" 
      req.Headers("Accept-Encoding") = "gzip,deflate" 
      req.ContentType = "application/soap+xml; charset=UTF-8" 

      If compressionRequested = True Then 
       '' if you want to receive compressed response 

       req.Headers.Add("Accept-Encoding", "gzip, deflate") 
      End If 
      Dim stOut As New StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII) 

      stOut.Write(xml.ToString) 
      stOut.Close() 


      Using resp As HttpWebResponse = DirectCast(req.GetResponse(), HttpWebResponse) 
       If resp.ContentEncoding = "gzip" Then 


        Dim st As Stream = resp.GetResponseStream() 
        If resp.ContentEncoding.ToLower().Contains("gzip") Then 
         st = New System.IO.Compression.GZipStream(st, System.IO.Compression.CompressionMode.Decompress) 
        ElseIf resp.ContentEncoding.ToLower().Contains("deflate") Then 
         st = New System.IO.Compression.DeflateStream(st, System.IO.Compression.CompressionMode.Decompress) 
        End If 
        Dim bfst As BufferedStream = New BufferedStream(st) 
        Using stIn As New StreamReader(bfst, Encoding.[Default]) 
         respXml = stIn.ReadToEnd() 


         stIn.Close() 
        End Using 

       Else 
        Using stIn As New StreamReader(resp.GetResponseStream()) 
         respXml = stIn.ReadToEnd() 

         stIn.Close() 
        End Using 
       End If 
      End Using 

     End Using 

aussi dans web.config Je configuré ceci:

<system.net> 
<connectionManagement> 
     <add address="*" maxconnection="100" /> 
     </connectionManagement> 
    <settings> 
     <servicePointManager expect100Continue="true" /> 
    </settings> 
    </system.net> 

Y at-il suggérer où est le problème et comment le résoudre?

Répondre

0

En ajoutant un GC.Collect() avant ce code tout fonctionne bien,