all groups > dotnet remoting > april 2007 >
You're in the

dotnet remoting

group:

how to implement pinging



how to implement pinging Robert Ludig
4/11/2007 12:46:25 AM
dotnet remoting: I have a long running remoting client that every once in a while calls
a method on a remoting server. The client constantly displays the
connection status. How can the remoting client find out that the
remoting server has become unavailable right after it happend?
Does .NET Remoting have any built in ping-like functionality? What is
the best practice in .NET Remoting for (keep) alive probing?
Re: how to implement pinging Spam Catcher
4/11/2007 6:59:00 PM
"Robert Ludig" <schwertfischtrombose@gmx.de> wrote in
news:1176277585.267836.321700@n59g2000hsh.googlegroups.com:

[quoted text, click to view]

Unfortunately no - not in the default channels.

You'll need something like Geniune Channels.

However, with the built in channels, just create a timer and fire off a
function call to a dummy function on the server. If the function times out
Re: how to implement pinging Robert Ludig
4/11/2007 10:56:04 PM
[quoted text, click to view]

There is only one problem with you suggested approach:
How do I control the timeout? When I call the remote server that is
not reachable the application hangs for a long time. (I haven't
figured out yet where that timespan comes from.) Not only do I want my
app to not hang but also I would like to specify my own timeout
timespan. I could of course call the ping in a dedicated thread and
kill that thread if it does not return for a specified timespan but
one thread for each ping and each remoting client? That'd be a hell of
a lot threads.

Re: how to implement pinging Spam Catcher
4/12/2007 6:59:08 PM
"Robert Ludig" <schwertfischtrombose@gmx.de> wrote in
news:1176357364.698091.170770@y5g2000hsa.googlegroups.com:

[quoted text, click to view]

Run the ping in a separate thread so it does not lock up your GUI
thread.

[quoted text, click to view]

I think you can specify the timeout on certain .NET channels during the
setup. Check the configuration parameters ...


[quoted text, click to view]

You don't need to create multiple ping threads. Just have each client
ping the server with 1 thread (and reuse the thread). The server
Re: how to implement pinging Robert Ludig
4/12/2007 11:19:44 PM
[quoted text, click to view]

Yes I have tried that. But those timouts do not seem have any effect
in case the server is not reachable.
This is how I did it:

Hashtable properties = new Hashtable();
properties.Add("port", 0); // let system pick an open port
properties.Add("timeout", 10000); // 10 second timeout...
IClientChannelSinkProvider provider = new
BinaryClientFormatterSinkProvider();
provider.Next = new CompressedClientChannelSinkProvider();
HttpChannel channel = new HttpChannel(properties, provider, null);
channel.WantsToListen = false;
ChannelServices.RegisterChannel(channel);

Anything wrong with that?



[quoted text, click to view]

Re: how to implement pinging Phil Wilson
4/19/2007 8:30:54 PM
More recent OS versions have the WMI Win32_PingStatus class that you can
call using the Management classes.

There are some C# implementations out there, like this one:

http://www.codeproject.com/dotnet/CSharpPing.asp

--
Phil Wilson
[Microsoft MVP-Windows Installer]

[quoted text, click to view]

Re: how to implement pinging Robert Ludig
5/11/2007 3:03:56 AM
This not an option because it doen't ping the actual remoting objects.
There is no way to guarantee that the remote object is available.
While the host (aka the remote machine) might be pingable that doesn't
mean that the remoting server on a specifc port and remoting uri is
available on that machine.

Also if you wanted pinging the way you described there is no need to
use wmi. You can simply use the ping class of the .NET Framework:

http://msdn2.microsoft.com/en-us/library/system.net.networkinformation.ping.aspx

[quoted text, click to view]

AddThis Social Bookmark Button