473,804 Members | 3,029 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2092
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 : executionTimeou t= (in seconds)
Ex:
<system.web>
<httpRuntime executionTimeou t="90" maxRequestLengt h="4096"
useFullyQualifi edRedirectUrl=" false" minFreeThreads= "8"
minLocalRequest FreeThreads="4" appRequestQueue Limit="100"
enableVersionHe ader="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
2631
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. I believe one is in the asp pages for the session itself, and the other is more of a system timeout settting in IIS. Would one of these supercede the other if the two are different? I have already looked at the time out setting in IIS, and it...
1
1327
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 server during query" Any ideas? I've never had this problem until now.
4
15473
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 | Properties | Configuration | Options | Enable Session State Session timeout 20 (3) within Global.asax.vb file - Session_Start subroutine can use Session.Timeout=x minutes or (4) within any web page, i.e., <web page>.aspx can use...
4
9463
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 the forms authentication to be a large value for that page also. TIA - Jeff.
22
5299
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: print "Oops - took too long!"
25
6105
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
11291
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 would implement an interrupt driven model, but the external device (which is connected via USB) does not support interrupts therefore the device needs to be polled at a specific interval. So my question is how can I implement a "deterministic"...
5
3783
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 after 20 minutes, i cannot set a timeout greater than 20 minutes. Our configuration is the following: - Server with Win2003, i.e. IIS 6.0 - Web application developed with vb.net simply composed by:
2
6449
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 string timeout is set to 3000s. SQL Command timeout is set to 3000s. IIS Connection Timeout is set to 120s. ASP.NET script timeout is not set so must use default of 90s.
0
9706
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9579
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10326
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10075
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9143
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7615
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4295
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3815
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2990
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.