By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,636 Members | 1,693 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,636 IT Pros & Developers. It's quick & easy.

Remoting - Detect a crashed/disconnected client from the server?

P: n/a
OK, after lots of faffing I have finally gotten remoting working - basically
I have a windows service (the "server") and a forms app (the "client").

The forms app can call methods in the server, and I can get events fired on
the server to be picked up and acted on in the client app, so all is well. I
can even get two client apps on different machines talking to the same
server instance and the events pop up on both.

This is all good until the "first" client app instance dies unexpectedly
(i.e. for testing, I am just killing it in task manager). The events never
reach the other instance, as the server seems to be sending out the events
synchronously to any connected clients. (I have got some code to unregister
the client/event in the form close event, so if you quit "gracefully" this
problem doesn't occur).

Is there any way of either a) removing a crashed client from the servers
internal list? (I do get an exception in the server when my event is fired,
basically saying the target machine actively refused connection - but what
to do with that info!) or b) can I send out my events from the server in
some async/simultaneous way so it doesn't matter if a client instance has
died or not.

I'd prefer option a as it seems neater, but hey-ho.

TIA

James.

Feb 25 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
James,

When you get the reference to the client, you have an object that
derives from MarshalByRefObject. With that, you can call GetLifeTimeService
which will return an object. This object can be cast to an ILease instance
which you would then query to get the state of the connection back to the
client. If the state indicates that it is not connected (or an exception is
thrown), then you can try and unsubscribe through the ILease interface, and
proceed from there.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"JamesB" <ja****@somewhere.com.net.com.netwrote in message
news:47**********************@news.zen.co.uk...
OK, after lots of faffing I have finally gotten remoting working -
basically I have a windows service (the "server") and a forms app (the
"client").

The forms app can call methods in the server, and I can get events fired
on the server to be picked up and acted on in the client app, so all is
well. I can even get two client apps on different machines talking to the
same server instance and the events pop up on both.

This is all good until the "first" client app instance dies unexpectedly
(i.e. for testing, I am just killing it in task manager). The events never
reach the other instance, as the server seems to be sending out the events
synchronously to any connected clients. (I have got some code to
unregister the client/event in the form close event, so if you quit
"gracefully" this problem doesn't occur).

Is there any way of either a) removing a crashed client from the servers
internal list? (I do get an exception in the server when my event is
fired, basically saying the target machine actively refused connection -
but what to do with that info!) or b) can I send out my events from the
server in some async/simultaneous way so it doesn't matter if a client
instance has died or not.

I'd prefer option a as it seems neater, but hey-ho.

TIA

James.

Feb 25 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.