Solved

C# - Stress testing a Web Service - Timeout

Posted on 2007-11-19
7
1,717 Views
Last Modified: 2013-11-07
Hi,

I have a web service that is query'ing a database. The query takes a few seconds to run.

I'm stress testing my web service using a couple of threads.

If the interval is too short between the threads that execute the web service, I get the following exception.

System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> Error fetching *MyWebserviceMethods*.
   at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)

Any ideas why this is happening? I thought web services can handle some load.

Thank you.
0
Comment
Question by:Endelm
  • 4
  • 2
7 Comments
 
LVL 6

Expert Comment

by:ventaur
Comment Utility
How are you calling the web service method?
0
 

Author Comment

by:Endelm
Comment Utility
I'm using a while loop and 3 threads.

I execute the 3 threads at the same time.....then sleep for 1 sec.....then run the 3 threads again, etc.

If I set the threads to sleep for 5 or 10 seconds I don't get this error.

The execution of each web service call takes a few seconds.

Thank you.
0
 
LVL 6

Accepted Solution

by:
ventaur earned 500 total points
Comment Utility
I think you'll need to call the web service method asynchronously to avoid the problem.
private void MyMethodCompleted(Object sender, localhost.MyMethodCompletedEventArgs Completed) {

  // Do something once the web service method, "MyMethod", has completed.

}
 

...
 

// Create the web service and attach an event for the method's completion.

MyWebserviceMethods Service = new localhost.MyWebserviceMethods();

Service.MyMethodCompleted += new localhost.MyMethodCompletedEventHandler(MyMethodCompleted);
 

// Call the web service method asynchronously.

Service.MyMethodAsync();

Open in new window

0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:Endelm
Comment Utility
Interesting.

What does this do and how is it different from what I was doing?

Thank you! :)
0
 
LVL 6

Expert Comment

by:ventaur
Comment Utility
If you call your web service method's xxxAsync version, it will automatically occur on its own thread; thus, preventing blocking. However, if you wish to perform any action(s) upon the completion of the method call, you have to subscribe to its xxxCompleted event.
0
 
LVL 1

Expert Comment

by:adam_ingeniti
Comment Utility
So in other words, "asynchronous" means that each call to the web service will occur on its own thread, and thus should not interfere with each other.
0
 
LVL 6

Expert Comment

by:ventaur
Comment Utility
You pretty much have it with that statement.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now