Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Remoting / March 2008

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JamesB - 25 Feb 2008 20:59 GMT
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.
Nicholas Paldino [.NET/C# MVP] - 25 Feb 2008 21:13 GMT
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.

Signature

         - Nicholas Paldino [.NET/C# MVP]
         - mvp@spam.guard.caspershouse.com

> OK, after lots of faffing I have finally gotten remoting working -
> basically I have a windows service (the "server") and a forms app (the
[quoted text clipped - 24 lines]
>
> James.
Efrain Ruiz - 29 Feb 2008 00:43 GMT
I am having the EXACT problem with a chat system I have running. As long
as the clients logoff via the proper ways such as FILE | EXIT or
clicking the top right X button, everything is fine and dandy.

As soon as the client crashes or is shutdown via the Task Manager, the
server shoots an error message saying this:

"An existing connection was forcibly closed by the remote host"

After this, the server does not close the connection nor removes the
client from it's client list.

Only way to get everything back to normal, is to shutdown the server and
restart it.

Anyway to fix this, please?
Tommaso Caldarola - 29 Feb 2008 10:09 GMT
> I am having the EXACT problem with a chat system I have running. As long
> as the clients logoff via the proper ways such as FILE | EXIT or
[quoted text clipped - 12 lines]
>
> Anyway to fix this, please?

My solution (a SAO creates a CAO for each connection) is based on this
article (http://www.codeproject.com/KB/IP/remotingandevents.aspx).
I have customized the second solution implementing a ping method called
by the server, if the call throws an exception (no connection) I remove
the client (disposing the CAO).
JamesB - 07 Mar 2008 17:06 GMT
>> I am having the EXACT problem with a chat system I have running. As long
>> as the clients logoff via the proper ways such as FILE | EXIT or
[quoted text clipped - 18 lines]
> the server, if the call throws an exception (no connection) I remove the
> client (disposing the CAO).

I'll look through that - I made a slight bit of headway by sending my
messages async so if a client has disconnected "dirtily", the other
client(s) still receive messages. But I'm pretty sure that's going to lead
to memory leaks and gawd knows what, so the above will be my next bit o'
reading...

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.