Threading within a service

S

Shoff

Hi there,

I hope someone can help me.

I have a client app. being used by about 50 users. When thy open the
app, it calls a webservice on a local server to check what items the
user can access, and returns a list for them to choose from.

To build the list, the web service calls other web services
asynchronously, and aslo starts another thread to call a SQL server
database and get a dataset.

Everything works fine with one machine, but after rolling it out to
all the users, I find that every now and again the users first get an
"Underlying connectin was closed" error. By restarting the
application again they go in fine.

Have done some tests with ACT which also reflects this with only a 66%
success rate on the web service.

I cannot see how I can change the process on the web server as it
needs to bring back that data, and although if I put everything
synchronously it either times out or takes unacceptably long to return
the data.

The network is a standard 100MB line, and the server is local, with
Gigs of memory, 4 processors the lot.

If anyone has any ideas, I would appreciate any help.

Thanks.
 
N

news.icon.co.za

Hi,

If running your data collection routines in parallel is the only solution
then you need to carefully manage your threads. The connection is being
closed because of an exception being thrown in your application, probably in
your asynchronous calls. Exceptions cannot traverse threads, and so your
main method is waiting indefinitely until a timeout occurs (which is also an
exception).

One solution is to increase the timeout value on your proxies to the other
web methods. As for an asynchronous call to the database, this is not a good
idea in a service based environment. By the way you can increase the timeout
on your database connection object too.

Increase timeout on web method proxy:
SoapHttpClientProtocol.Timeout = 180; // this is in milliseconds
Increase timeout on database command execution
SqlCommand.CommandTimeout = 180; // this is in milliseconds.

Hope this helps,

Luke Venediger
http://blogdotnet.blogspot.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top