Unable to connect to remote server - When consuming webservice C #

7

I have an application developed in C # which consumes a webservice also in C #.

In some cases (it is not always and is not everywhere / clients) at the time of consuming webservice I get the following error:

  

Unable to connect to remote server
    A connection attempt failed because the connected component did not respond     correctly after a period of time or the established connection failed     because the connected host did not respond meuip: 80

I already had problems with another error (which burst on the same line) that was:

  

Error description: The remote name could not be resolved: 'webservices.meusite.com'

But I managed to solve it just by repeating the attempt if there was an error.

The stacktrace shows the following:

em System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
   em System.Net.HttpWebRequest.GetRequestStream()
   em System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
   em Updater.WebServ.Servico.Metodo(Int32 Id)
   em Updater.TelaPrincipal.btTeste_click(Object sender, EventArgs e)

The most intriguing of all is that it does not matter how many times I try here, it never makes a mistake. The problem is only in some places.

What could be causing this?

    
asked by anonymous 04.03.2015 / 13:29

1 answer

4

The problem should be Timeout, try configuring the Timeout keys in the bindings key of the client software configuration file.

     <basicHttpBinding>
        <binding name="WebServiceSoap"
                 closeTimeout="00:30:00"
                 openTimeout="00:30:00"
                 receiveTimeout="00:30:00"
                 sendTimeout="00:30:00"
                 allowCookies="false"
                 bypassProxyOnLocal="false"
                 hostNameComparisonMode="StrongWildcard"
                 maxBufferSize="655360"
                 maxBufferPoolSize="524288"
                 maxReceivedMessageSize="655360"
                 messageEncoding="Text"
                 textEncoding="utf-8"
                 transferMode="Buffered"
                 useDefaultWebProxy="true">
          <readerQuotas maxDepth="32"
                        maxStringContentLength="8192"
                        maxArrayLength="1638400"
                        maxBytesPerRead="40960"
                        maxNameTableCharCount="16384" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    
04.03.2015 / 15:36