473,221 Members | 2,423 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,221 software developers and data experts.

Creating a timeout

I have a webservice which takes a hostname and drive letter as input and
returns the free space for that drive on that host as a long. Sometimes
it will take forever to get information from a recalcitrant host, but it
keeps trying far longer than I want it to. How can I set up a timeout
for the process, so that after a couple of seconds it returns a failure
status and gives up waiting?

Currently, the method maps the drive, finds its available space, and
then unmaps it, which all works quite neatly. If the host doesn't exist
or the drive doesn't exist it returns -1. Otherwise it returns the free
space in bytes as a long. We're currently experiencing network
difficulties because of a relocation. Most of our important business
systems, including DNS servers and the like, are now about 10 miles away
and are accessed via a much, much slower link than we're used to. Some
hosts simply take ages to respond and I'd like to impose a timeout
somehow. I thought maybe some sort of timer based arrangement might
work, but now that I'm trying it I can't actually work out what needs to
be done.

Any help would be appreciated.
*** Sent via Developersdex http://www.developersdex.com ***
Dec 22 '05 #1
3 2070
There is a parameter on the Machine.Config file (or you can put it on your
Web.Config file to affect only your website) called@

httpRuntime, attribute : executionTimeout= (in seconds)
Ex:
<system.web>
<httpRuntime executionTimeout="90" maxRequestLength="4096"
useFullyQualifiedRedirectUrl="false" minFreeThreads="8"
minLocalRequestFreeThreads="4" appRequestQueueLimit="100"
enableVersionHeader="true"/>
<system.web>

This will timeout after 90 seconds

Cheers

--
Salvador Alvarez Patuel
Exony Ltd - London, UK
"Adam Short" wrote:
I have a webservice which takes a hostname and drive letter as input and
returns the free space for that drive on that host as a long. Sometimes
it will take forever to get information from a recalcitrant host, but it
keeps trying far longer than I want it to. How can I set up a timeout
for the process, so that after a couple of seconds it returns a failure
status and gives up waiting?

Currently, the method maps the drive, finds its available space, and
then unmaps it, which all works quite neatly. If the host doesn't exist
or the drive doesn't exist it returns -1. Otherwise it returns the free
space in bytes as a long. We're currently experiencing network
difficulties because of a relocation. Most of our important business
systems, including DNS servers and the like, are now about 10 miles away
and are accessed via a much, much slower link than we're used to. Some
hosts simply take ages to respond and I'd like to impose a timeout
somehow. I thought maybe some sort of timer based arrangement might
work, but now that I'm trying it I can't actually work out what needs to
be done.

Any help would be appreciated.
*** Sent via Developersdex http://www.developersdex.com ***

Dec 22 '05 #2
One idea would be to use different threads. Currently I'm working in
1.1, but I know the 2.0 framework has a read timeout on a socket. To
get that same functionality, I perform the read in a seperate thread,
use a flag to determine if it has completed or if it's still blocking,
and monitor that for x milliseconds. If the time passes and the method
is still blocking I just kill the thread. It's rather complicated and
probably a little dangerous, so I would make sure that you have a firm
understanding of threads in .NET.

If this sounds like something you would like to try and you would like
to see some code let me know. Hope this helps ~ Justin

Dec 22 '05 #3
Hi Justin,

It will not work on a webservice environment, if I call a function
asynchronicly on a webservice and you start the reading in another thread the
function will never return anything, what is more, you should never abort a
thread (you can not kill it otherwise), it is considered bad practice and
will raise an exception. In order to do what you want you should use the same
thread where the calling come from and use the Monitor.Enter function with a
explicit timeout, but is not recommended in this scenario.

Hope this helps to enhance the threads experience.
Regards

--
Salvador Alvarez Patuel
Exony Ltd - London, UK
"Justin Creasy" wrote:
One idea would be to use different threads. Currently I'm working in
1.1, but I know the 2.0 framework has a read timeout on a socket. To
get that same functionality, I perform the read in a seperate thread,
use a flag to determine if it has completed or if it's still blocking,
and monitor that for x milliseconds. If the time passes and the method
is still blocking I just kill the thread. It's rather complicated and
probably a little dangerous, so I would make sure that you have a firm
understanding of threads in .NET.

If this sounds like something you would like to try and you would like
to see some code let me know. Hope this helps ~ Justin

Dec 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: E Sullivan | last post by:
I am having a time out issue when multiple users are accessing the server. This time out does not happen all of the time. My understanding is that the time out value is actually set in two places....
1
by: Ken | last post by:
Hi, I just upgraded to Mandriva 2005 and I'm having issues creating users in mysql. I'm doing the user creation using webmin. I keep getting the following error "Lost connection to MySQL...
4
by: DavidS | last post by:
First: There are several ways to confuse one regarding session timeout. (1) web.config - <sessionState timeout="20"> (2) IIS Manager | Internet Information Services | ServerNode | Default Web Site...
4
by: UJ | last post by:
I have a page where the user can upload a video file. As you can guess, this may take a while. Is there a way I can change the session timeout for just this one page? I would also want to change...
22
by: Nick Craig-Wood | last post by:
Did anyone write a contextmanager implementing a timeout for python2.5? I'd love to be able to write something like with timeout(5.0) as exceeded: some_long_running_stuff() if exceeded:...
25
by: =?Utf-8?B?RGF2aWQgVGhpZWxlbg==?= | last post by:
I tried: <sessionState timeout="1"> </sessionState> bounced IIS, and after 1 minute still had a session. ??? -- thanks - dave
13
by: LordHog | last post by:
Hello all, I have a little application that needs to poll a device (CAN communications) every 10 to 15 ms otherwise the hardware buffer might overflow when there are message burst on the bus. I...
5
by: Masso | last post by:
Hallo to the group, my question is this: where i have to set timeout in a web application? If i set into sessionState with property Timeout="60", after 20 minutes the session is over. Always...
2
by: JimLad | last post by:
Hi, I've got a very basic asp.net page that accesses a very slow db query and siplays to screen. I'm hitting a timeout aftre about 3.5 to 4.5 minutes - seems to be variable. SQL connection...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.