[Mono-list] A couple of Remoting Questions

RoBiK robik@mailbox.sk
Tue, 11 May 2004 12:35:16 +0200


 
Hi,

1) You do not need a configuration file, but you must somehow configure the
remoting inside your application. You have two options:
- Call RemotingConfiguration.Configure(). You can use null as the filename
parameter. Passing a null reference as the filename parameter will cause
default remoting initialization without requiring the existence of a
configuration file.
Example: "RemotingConfiguration.Configure(null);"
- Call at least ChannelServices.RegisterChannel() passing as a parameter an
instance of channel class (in your case HttpChannel Class). You do not need
to define the port on the client side.
Example: "ChannelServices.RegisterChannel(new HttpChannel());"

2) I have RH9 with mono beta 1 installed. I have run your app for about 30
times (and also my own apps many times in past), but never seen such a
strange behavior... Everything works nice and clean, no asserts, no left
behind processes. I have no idea what's wrong.

3) Here ist the soap specification http://www.w3.org/TR/soap/ and here
http://msdn.microsoft.com/library/en-us/dnsoap/html/understandsoap.asp an
article from microsoft regarding soap (with good examples). For monitoring
purpouses you can find a couple of http and/or soap sniffers to use. You can
also code a simple port forwarder wich copies the messages to the console to
watch the trafic.

Robert

-----Original Message-----
From: Jonathan Stowe [mailto:jns@gellyfish.com]
Sent: Montag, 10. Mai 2004 14:21
To: Mono-List
Subject: [Mono-list] A couple of Remoting Questions

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("RemotingTes
t.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.


_______________________________________________
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list