473,385 Members | 1,782 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,385 software developers and data experts.

Timeout Errors

Hello,

I have a desktop app that retrieves data from a web service, It has worked
really good for over a year, but there is an ongoing problem that I have not
been able to fix.

When the client is not online, it take over 90 seconds for the application
to through a exception that the underline connection is closed.

This there a way to speed this up. Instead of it taking 90 seconds,
something like 15 seconds?

I am testing the connection to the web service by called a function called
ISOnline.
All it does is return a True

If true is not returned then I do something else, but I still get a timeout
exception...
Any Assistance would be greatly appreciated.

Thanks,

Chuck
Nov 23 '05 #1
1 1721
Chuck,

The client-side timeout is specified by the Timeout property of the
proxy class.
I.e.

Service1 ws = new Service1();
ws.Timeout = 90000; // 90 seconds
ws.DoMethod();

I would also suggest that instead of just waiting for connection
timeout, you may want to pro-actively determine if the machine is
connected or not, before you even make the webservice call. This would
let your application begin to act more like a smart client, that is
able to determine it's own status and take the approriate actions based
on that status.

There are a couple of methods you can use for to determine if you are
online or not. The first one is pretty simple to use and determines if
the machine has a valid internet connection. This is the same method
used by IE to determine if the user if online or offline.

using System.Runtime.InteropServices;

[DllImport("wininet.dll")]
private extern static bool InternetGetConnectedState( out int
connectionDescription, int reservedValue ) ;

public bool IsConnected()
{
int connectionDescription = 0;
return InternetGetConnectedState(out connectionDescription, 0);
}
This second method will tell you if you are connected to a network and
identifies the type, i.e. LAN or WAN.

using System.Runtime.InteropServices;

[DllImport("sensapi.dll" ) ]
public static extern bool IsNetworkAlive( out int flags );

if( IsNetworkAlive( out flags ) )
MessageBox.Show( "Network connected, flags:" + flags.ToString() );
else
MessageBox.Show( "Network NOT connected!" );

Your third option, scans your network devices and tells you if any of
them are connected. This is the only one that will detect an unplugged
cable scenario. I.e. You were connected, but the cable was unplugged
since then. The previous two methods would still return a incorrect
"true" value under that condition.

using System.Runtime.InteropServices;
using System.Management;

static bool IsActiveConnection()
{
ManagementClass managementClass = new ManagementClass( @"root\WMI",
@"MSNdis_MediaConnectStatus", null );
ManagementObjectCollection DeviceCollection =
managementClass.GetInstances();

foreach( ManagementObject device in DeviceCollection )
{
string name = (string) device["InstanceName"];
bool active = (bool) device["Active"];
uint status = (uint) device["NdisMediaConnectStatus"];
if (status == 0)
{
//We've found at least one live connection
return(true);
}
}
//No live connections were found
return(false);
}

Hope that helps

Peter Kelcey

Nov 23 '05 #2

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

Similar topics

4
by: Cath B | last post by:
I am pretty sure I am getting a command timeout when execute a SQL procedure that has an output parameter. The code below is in an asp page that is called using RSGetASPObject. I want to be able...
0
by: Steve - DND | last post by:
We are continually receiving timeout, and "Unable to write data to the transport connection" errors while using the System.Net.HttpWebRequest class from an ASP.Net web page. Below are the two...
2
by: Chris Langston | last post by:
I have a Web Server running IIS 5 or 6 on Windows 2K and Windows 2003 Server that is experiencing strange shutdown problems. We are using ASP.NET v1.1 and our application is written in VB.NET ...
1
by: Brent | last post by:
I thought I was doing a simple thing, here -- asking a server for a text document, getting the first 150 lines, and then returning the lines. But I keep getting timeout errors: "Exception...
2
by: peterlan | last post by:
Hi, this is a follow-up to my previous post. I've got a long-running function exposed as a web service. It can take up to 3 or 4 minutes to complete (rendering a 300 page pdf from xsl-fo). I have...
0
by: Barb | last post by:
Hello, I have a (C#) web service being consumed by a high volume "asp classic" site. It worked perfectly until I tried consuming a second web service from the first web service. Both services...
5
by: yawnmoth | last post by:
Say I have the following script: <? $timeout = 5; $start = time(); $fsock = fsockopen('125.1.119.10',80,$errno,$errstr,$timeout); // reduce $timeout by the amount of time that it took for...
1
by: a.r.austin | last post by:
Hello, I am trying to download a few files one after another from a remote server. Problem is that I don't know how to, or if I am able at all, set a time out for download. I don't want to time...
2
by: Robin Becker | last post by:
While messing about with some deliberate socket timeout code I got an unexpected timeout after 20 seconds when my code was doing socket.setdefaulttimeout(120). Closer inspection revealed that...
1
by: alvinstraight38 | last post by:
I have a client who has been receiving hundreds of SQL timeout error messages in their error logs. Specifically, the message looks like this: MESSAGE :...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.