469,924 Members | 1,529 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,924 developers. It's quick & easy.

Loss Of Network Connection During Webservice Call

I have an app that calls a webmethod. Everything works fine except when you,
the client, loses network connectivity during the request. When the
connection is lost the client applications hangs.

I tried setting the Timeout property on the client but still an error is
never raised. Is there a workaround for this?
Aug 30 '07 #1
6 2541
"Tim" <Ti*@discussions.microsoft.comwrote in message
news:A2**********************************@microsof t.com...
>I have an app that calls a webmethod. Everything works fine except when
you,
the client, loses network connectivity during the request. When the
connection is lost the client applications hangs.

I tried setting the Timeout property on the client but still an error is
never raised. Is there a workaround for this?
Is there a workaround for what? In what way does the client hang? In what
part of the conversation does the client hang?
--------------------------------------------------------------------------------
John Saunders | MVP – Windows Server System – Connected System Developer

Aug 31 '07 #2


"John Saunders [MVP]" wrote:
"Tim" <Ti*@discussions.microsoft.comwrote in message
news:A2**********************************@microsof t.com...
I have an app that calls a webmethod. Everything works fine except when
you,
the client, loses network connectivity during the request. When the
connection is lost the client applications hangs.

I tried setting the Timeout property on the client but still an error is
never raised. Is there a workaround for this?

Is there a workaround for what? In what way does the client hang? In what
part of the conversation does the client hang?
--------------------------------------------------------------------------------
John Saunders | MVP – Windows Server System – Connected System Developer

Lets start with what I want to do. I have mobile users that will have a
client that will randomly phone home to look for updated presentations,
literature, videos, etc. The client computer will decide what is new, updated
or has been deleted . Then the client will download the files in chunks and
save them to a designated place until completed. Then the file will be moved
to its final destination.

We want this to be automatic, no user intervention. The problem is if it is
in the middle of a download (webmethod call) when they disconnect from there
wireless connection or LAN the application will not complete the following
code.

1. Dim bytes() as byte
2. using ws as new wsService.FileSystem
3. bytes = ws.GetFile(fileName, startIndex, length)
4. end using
5. ........

GetFile is a method that returns x number of bytes of a file starting at an
offset (startIndex) and return x (length) number of bytes.

This function works great under normal conditions. Now lets say the service
is invoked on line 3. This function may take a while to return a value
depending on the amount of data you want returned. Now you unplug the network
cable before the method returns from the client computer which is calling
this method. The method will not return and an exception is not raised. I
have let it sit there for 5-10 minutes and then I do a break all and the
debugger stops at line 3.

I have tried setting the .Timeout property (ws.Timeout = 5000) and an
exception is not raised. I am using synchronous calls and really do not want
to goto an asynchronous design (I do not know if it would make a difference).

Shouldn't an exception be raised within some reasonable timeframe? Setting
the .Timeout does not seem to work. I just want the webmethod to return or
raise an exception so that I know to try again later.

Have any suggestions?
Aug 31 '07 #3
"Tim" <Ti*@discussions.microsoft.comwrote in message
news:A8**********************************@microsof t.com...
>

"John Saunders [MVP]" wrote:
>"Tim" <Ti*@discussions.microsoft.comwrote in message
news:A2**********************************@microso ft.com...
>I have an app that calls a webmethod. Everything works fine except when
you,
the client, loses network connectivity during the request. When the
connection is lost the client applications hangs.

I tried setting the Timeout property on the client but still an error
is
never raised. Is there a workaround for this?

Is there a workaround for what? In what way does the client hang? In what
part of the conversation does the client hang?
--------------------------------------------------------------------------------
John Saunders | MVP – Windows Server System – Connected System Developer

....
1. Dim bytes() as byte
2. using ws as new wsService.FileSystem
3. bytes = ws.GetFile(fileName, startIndex, length)
4. end using
5. ........
....
This function works great under normal conditions. Now lets say the
service
is invoked on line 3. This function may take a while to return a value
depending on the amount of data you want returned. Now you unplug the
network
cable before the method returns from the client computer which is calling
this method. The method will not return and an exception is not raised. I
have let it sit there for 5-10 minutes and then I do a break all and the
debugger stops at line 3.
Good analysis.

You say that the debugger stops at line three, but that's unlikely. Look at
the Call Stack window, and turn on display of non-native code, calls to
other threads, etc. You will find that the code was waiting for something in
code _called by_ line three.

You need to see what code that is. In particular, TCP/IP based protocols
will not always time out at all parts of the communications cycle. They may
not even notice that the other side is not reachable. If this is important
to you, then you may need to implement that sort of timeout on your own.

Although this may seem like a natural part of networking, the fact is that
most applications don't need this feature. It would be wasteful for this to
be enabled on all TCP/IP connections, so it isn't.

--------------------------------------------------------------------------------
John Saunders | MVP – Windows Server System – Connected System Developer

Sep 1 '07 #4
I have an app that calls a webmethod. Everything works fine except when you,
the client, loses network connectivity during the request. When the
connection is lost the client applications hangs.

I tried setting the Timeout property on the client but still an error is
never raised. Is there a workaround for this?
I have the same problem.
When I try to execute query to MS SQL Server (on another computer) whith ExecuteReader (C#). I unplug network cable and my application hangs.
During my research I noticed that it hangs during calls to windows sockets (WSARecv - function).
This problem occures on Windows 2003 Server.
On WinXP it works fine. When I unplug network cable it throws exception.
On WinXP WSARecv function returns control immediately.
On Win2003 it waits for timeout and doesn't understand that network is unavailable.

What Operation System do you use?

BizTalk Utilities - Frustration free BizTalk Adapters
http://www.topxml.com/biztalkutilities
Oct 8 '07 #5
What Operation System do you use?

Vista Business.....

I should have followed up in this thread. If I ran the debugger while
messing with the network I got the behaaviour like I described. However if I
ran teh application outside of the IDE then errors were thrown. So I had do a
little debugging outside the debugger.

Give that a try and see what happens....
Oct 8 '07 #6
=?Utf-8?B?VGlt?= <Ti*@discussions.microsoft.comwrote in
news:A8**********************************@microsof t.com:
>
1. Dim bytes() as byte
2. using ws as new wsService.FileSystem
3. bytes = ws.GetFile(fileName, startIndex, length)
4. end using
5. ........

GetFile is a method that returns x number of bytes of a file starting
at an offset (startIndex) and return x (length) number of bytes.
If you need to do file transfer, you should look at MTOM. MTOM allows you
to transfer large files in segements, thus having better control over
errors, and such. MTOM is part of WSE 3.0 add-on pack from MS.
Oct 9 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

26 posts views Thread by Rajeev Tipnis | last post: by
reply views Thread by John J. Hughes II | last post: by
3 posts views Thread by Martin B | last post: by
2 posts views Thread by =?Utf-8?B?RnJpZWRoZWxtRWljaGlu?= | last post: by
4 posts views Thread by =?Utf-8?B?QXJuYXVkIFZpc2N1c2k=?= | last post: by
7 posts views Thread by Christiano Donke | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.