Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Timeout Error when calling webservice

Posted on 2011-10-26
3
Medium Priority
?
431 Views
Last Modified: 2012-06-27
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
0
Comment
Question by:shieldguy
  • 2
3 Comments
 
LVL 17

Expert Comment

by:Carlos Villegas
ID: 37031756
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
 
LVL 1

Author Comment

by:shieldguy
ID: 37043585
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
 
LVL 17

Accepted Solution

by:
Carlos Villegas earned 2000 total points
ID: 37044449
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

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
Suggested Courses
Course of the Month10 days, 12 hours left to enroll

572 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question