[Mono-list] A couple of Remoting Questions

Jonathan Stowe jns@gellyfish.com
Mon, 10 May 2004 13:20:42 +0100


I have been playing around with remoting and a couple of things have
come up

I am trying a test based in the example in MS SDK:

Client:

using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Http;

namespace RemotingTest
{
  public class Client
  {
    public static void Main(string [] args)
    {
      RemotingConfiguration.Configure("remoting.config");
      HelloServer obj =
(HelloServer)Activator.GetObject(typeof(RemotingTest.HelloServer),
"http://localhost:8085/Hello");
      if (obj == null)
      {
         System.Console.WriteLine("Could not locate server");
      }
      else
      {
         string name = "blah";
         if ( args.Length > 0 )
         {
            name = args[0];
         }
         Console.WriteLine(obj.Hello(name));
      }
    }
  }
}


Server:

using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Http;

namespace RemotingTest
{
  public class Server
  {

    public static void Main(string [] args) {

      HttpChannel chan = new HttpChannel(8085);
      ChannelServices.RegisterChannel(chan);
     
RemotingConfiguration.RegisterWellKnownServiceType(Type.GetType("RemotingTest.HelloServer,Object"), "Hello", WellKnownObjectMode.SingleCall);
      System.Console.WriteLine("Hit <enter> to exit...");
      System.Console.ReadLine();
    }
  }
}

Test Class:

using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Http;
using System.Reflection;

namespace RemotingTest
{
  public class HelloServer : MarshalByRefObject
  {

    public HelloServer()
    {
      Console.WriteLine(this.ToString() + " activated");
    }

    public String Hello(String name)
    {
      Console.WriteLine("HelloServer.Hello : {0}", name);
      return String.Format("Hi there {0}", name);
    }
  }
}


Firstly, unlike using the MS.NET SDK it will not work unless one loads
the configuration like:

<configuration>
   <system.runtime.remoting>
      <application>
         <client>
         </client>
         <channels>
            <channel
               ref="http"
               port="0"
            />
         </channels>
      </application>
   </system.runtime.remoting>
</configuration>

I was wondering why the difference in behaviour - does windows have the
http channels already registered in some default configuration which
mono doesn't have or is there a difference in behaviour of
ChannelServices.RegisterChannel() in the mono library - I notice that
the registered channels are stored in a static array in the
ChannelServices class so it strikes me that another program is not going
to have access to this - or am I missing something here?  It would be
nice to have an example that worked the same with both mono and the MS
SDK.

Secondly I am getting weird intermittent behaviour from both server and
client code - every once in a while I am getting:

** (process:5787): ERROR (recursed) **: file class.c: line 1272
(mono_class_init): assertion failed: (class)
aborting...

from the client code, which appears to hang afterwards - the server
however behaves as expected.  I am unable to reproduce this at will
however.

I also am occasionally getting:

 
** (server.exe:12805): WARNING **: : unref on 38 called when ref was
already 0
 
>From the server after the remote method has been called - again this is
intermittent and not reproducible at will.

It also appears that neither the client or the server are cleaning up
properly as there are parentless processes left behind (which I take to
be threads - but I never found out how to distinguish processes and
threads with 'ps' on Linux).  This is with Beta 1 on Mandrake 9.2 x86.

Finally does anyone know of any documentation regarding the SOAP
messages involved in http remoting or am I going to have to use a proxy
to dump the exchanges?

Thanks.