Remoting timeout issues

Are there any known workarounds for the really annoying lengthy remoting timeouts on down servers This is particularly a problem when using .Net remoting and the server isn't available, it can take up to 2-3 minutes for the line of code to timeout when accessing a remote object.

I have tried implementing a Ping class before I access the object, but sometimes this just doesn't work if the server is in the process of shutting down...

Obviously having an application hang for that long is unacceptable.. I am threading everything however my application will not cleanly close if the thread is hung waiting for a socket timeout.

A sample for you..


Answer this question

Remoting timeout issues

  • Christopher Lusardi

    Nope it seems no one really paid attention to the issue. It still exists and the only known workaround is to ping the server beforehand. I constantly get the answer "but it is supported, check the remotingtimeout property" but of course that has been tested to death and does not deal with the issue at all.



  • Jean-Pierre Fouche

    Thanks for the reply...

    It's the 45 second initial timeout that not acceptable in my situation, and I would assume this is a bit long for any application.

    I'm going to try to asynchronously open a raw TCP sockect connection to the TCPChannel on the server and use an AutoResetEvent and WaitOne with my own specified timeout. This will at least let me know the object is available for .Net remoting without having to wait the 45 seconds. I'll simply close the raw socket connection if a connection is established.


  • Juha Kauppila

    We "solved" this proble like this:

    The remoting server has a Method called Ping() wich just returns the current DateTime on the server (it would probably also work if this method doesn't return anything at all). On the remoting client we call Server.Ping() inside an extra thread. If the method didn't return after a certain time or an exception is thrown, the thread is aborted and we know the remoting connection is not available, and hence the server can be considered being offline. This is probably more expensive that opening an extra socket for pinging but really makes sure that not only the sever application is running/the server machine is up but also that the actual remoting connection can be established.



    // Ping the server in its own thread (so it doesn't block)

    Exception pingException = null;
    DateTime now = DateTime.Now;
    System.Threading.
    Thread pingThread = new System.Threading.Thread(delegate()
    {
      try
      {
        this.lastServerReply = this.remoteAdapter.Ping();
      }
      catch (Exception ex)
      {
        pingException = ex;
      }
    });
    pingThread.Start();
    if (pingThread.Join((int)this.pingWaitTime.TotalMilliseconds))
    {
      if (pingException == null)
      {
        // no exception was thrown and the thread was not aborted
        // so we know that the remoting connection is available
      }
    }

     



  • SyracuseCheer

    can you set both timeout and connectionTimeout properties and let us know the results.

    http://DotNetWithMe.blogspot.com
    vikas goyal



  • Paul Stringer

    The HTTP and TCP channel has timeout property that you can configure.

    - Vipul



  • Hexadecimator

    So... was this problem ever solved or addressed by Microsoft

  • Cute_Celina


    Hi, All:

    SocketPro at www.udaparts.com has three connection, receiving and sending timeouts for this type of problems. Why don't you give it a try

    Cheers



  • WinFormsUser13232

    Does anyone know of a good solution to this issue

    A ping solution doesn't work because the machine may be available but the host containing the required object may not be running.

    A general connection timeout property doesn't seem to be supported in .Net 2.0 when using a TCPChannel or HTTPChannel. The documentation only lists a connectionTimeout property for the IPCChannel.

    Thanks...


  • Bruce Thomas

    I do something similar to this, but it's a bit nasty to do if you have a large application that does alot of remoting. Granted it works, but still... any MS guys wanna chirp in on this subject

  • Parker Lewis

    correct, if the machine is in the process of booting then a ping solution could give funny results. If the machine is up and simply not hosting the object (for whatever reason) than it will timeout very quickly and throw an exception, however if the machine cannot respond then your client application hangs for a while...

    In case anyone is interested, the timeout seems to be around 45 seconds, almost exactly. The IPCChannel does contain a working timeout however it's no good for network communications obviously.



  • JonnyAJAX

    Rather than using .IsAlive why dont you write a Ping method at server, where you can just return "true".

    sKumar



  • Vladimir Bougay

    Sorry I keep forgetting to check this thread.. yea I tried both, and a few other things.. I had another developer tackle it as well but he found the same results. There's no apparent way to have .Net timeout connections to proxy's that don't exist (i.e. Server is completely offline)

    The only workable solution (which I think is a horrible way to do it) is to ping the server before making a request. If the ping times out, assume it's not available to make a connection. Of course the standard exception catching is still needed in case it's not hosting the object. This isn't terribly efficient, I'm just really suprised such an integrated part of .Net doesn't have a connection timeout implemented. If I'm wrong, point it out because no one I've introduced this to has been able to come up with a better solution.



  • Tom Janssen

    I've tried setting the timeout property in the channel via code, but it doesn't work at all. Doesnt seem to work on HTTP Channels either. I've seen references to it working (url here), but its not. I'm using the 2.0 framework (2.0.50727). Here's a code snippet (that times out after 3 minutes when remote server is turned off):

    int configport = 65001;
    string configserver = "server01";
    BinaryClientFormatterSinkProvider clientProvider = new BinaryClientFormatterSinkProvider();
    BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider();

    serverProvider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
    IDictionary props = new Hashtable();
    props[
    "port"] = 0;
    string s = System.Guid.NewGuid().ToString();
    props[
    "name"] = s;
    props[
    "typeFilterLevel"] = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
    props[
    "timeout"] = 2000;  // also tried connectionTimeout

    TcpChannel chan = new TcpChannel(props, clientProvider, serverProvider);
    //HttpChannel chan = new HttpChannel(props, clientProvider, serverProvider);
    ChannelServices.RegisterChannel(chan, false);

    MyObject remoteObject = (MyObject)Activator.GetObject(typeof(MyObject), String.Format("tcp://{1}:{0}/RemoteObject", configport, configserver));
    if (remoteObject.childObject != null) { }    // Throws an exception when server unavailable, timeout takes 3 minutes!

     



  • Remoting timeout issues