views:

147

answers:

2

Hello, I have a WCF service with a function GetData()

When my client calls this function,it takes a while to return the data after looping through some stuff

Within that period of time,if I pull of the wires on the server,no error is thrown.

How do I get to know if the client gets disconnected?

Thanks.

Edit:I'm using Wshttpbinding

+2  A: 

I don't know if this only works for duplex channel but you could subscribe to the client close event of the channel. Look at OperationContext.Current.Channel.Closed.

Blog post listed below has more info http://www.rcs-solutions.com/blog/2008/09/24/HandlingDisconnectsWithWCF.aspx

Emmanuel
+1  A: 

What kind of bindings and protocols are you using?

Typically, the server has no knowledge of the client, and will not know about the client disappearing. If you have a duplex binding, then you have a channel from the server going back to the client, and then you can use the technique described in the link Emmanuel posted.

Other than that - I do not know of any way the server could find out that the client has been disconnected before an error happens (e.g. a channel faults, since the client can't pick up the response anymore).

Marc

marc_s
ok, the solution was to have an id everytime a connection was made and and to return acknowledgement manually :(
Josh