Timeout Error when calling webservice

In my web site I am calling web service which works fine most of time but sometimes it give timeout error. see error below

"System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 195.123.10.18:8080 at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) --- End of inner exception stack trace --- at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context) at System.Net.HttpWebRequest.GetRequestStream() at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) "

In my website web.config I had increased the timeout in following
<httpRuntime executionTimeout
and  
<sessionState mode="InProc" timeout="
but still sometimes i get this timeout error when calling webservice

Any suggestion how to reolve this issue?

Should I need to increase the timeout on the server where the webservice is hosted if yes how can I do it?

Thanks
LVL 1
shieldguyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Carlos VillegasFull Stack .NET DeveloperCommented:
Hello, the System.Web.Services.Protocols.SoapHttpClientProtocol class has the Timeout property, the default value is 100000 ms (100 seconds), you can try by increasing this value on your client proxy, but I don't like too much this way... can you provide more info about your service so I can have a better view of what is going on? how many users access it? is hosted on IIS6/7? what is the average time for this method to complete? what you do inside your web method, connections to DB, file access, network access, etc..?

Reference:
http://msdn.microsoft.com/en-us/library/system.web.services.protocols.soaphttpclientprotocol.aspx
and
http://msdn.microsoft.com/en-us/library/system.web.services.protocols.webclientprotocol.timeout.aspx
0
shieldguyAuthor Commented:
This web service normally take about 20 - 40 secs to complete

It perform two task first get the payment details varification and second save the order details to the ERP system

Currently the problem is that I dont have the access to the code of web service

Thanks
0
Carlos VillegasFull Stack .NET DeveloperCommented:
Ok, you must take in consideration that network errors can happen, maybe instead of increasing the timeout value you can implement this small logic when you call that web service, if it throw you a timeout exception you can try one more time, if there is another timeout exception then something must be wrong and you can display a friendly message to your user, something like "try again in a few seconds".
Example:
int tryCounter = 0;
tryAgain:
try
{
    tryCounter++;
    CallMyWebMethod();
}
catch (TimeoutException)
{
    if (tryCounter < 2)
        goto tryAgain;

    throw;
}

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.