Groups | Blog | Home
all groups > dotnet remoting > august 2003 >

dotnet remoting : Multiple Servers, One Client and Remoting Events


sharipastore NO[at]SPAM yahoo.com
8/20/2003 12:40:46 PM
The goal is to have the identical servers running on several different
machines while sending events to one client located on one of the
machines. I can get remoting events to work for each server
individually, but I'm not sure how to register multiple URLs for each
server. I've tried using the Activator.CreateInstance with each url
attribute, but it raises the exception "Activation Attributes are not
supported for types not deriving from MarshalByRefObject". Well I'm
trying to register an interface since I am using remoting events. Any
way to get this to work???

Thanks in advance,

SEWilson
8/20/2003 6:36:24 PM
A single server should only need to register all of its
types and wait.

Clients will need to connect to each server and provide a
reference to an object (or in your case, subscribe to a
server-side event).

When an object reference travels from client to server,
source information is bound to it (so that the remote end
can re-establish contact), so clients cannot be on the
side of NAT or a Firewall that would prevent connecting to
the client from the server.

As far as creating objects from specific servers for the
event subscription, I'm unsure and curious myself. One
solution may be to produce a centralized service that
handles registration (all clients talk to that service for
service ObjRefs, all services provide that cetnralized
service with ObjRefs to supply to clients)

Objrefs could then be obtained from a client from a single
location, and probably as a tidy little ObjRef[].

ObjRef can be UnMarshal()'d when you need a typed
reference to the proxied object.

Hope that helps, please reply with your findings.
- Shaun


[quoted text, click to view]
SEWilson
8/20/2003 7:57:22 PM
[quoted text, click to view]

At this point you might always want to establish peer to
peer connections with other known servers. If you do this
be very careful to wrap access to any peer servers with
try/catch blocks since you don't want the failure of a
local method to cause a server to go down.

[quoted text, click to view]

You can use Activator.CreateInstance() to create an object
from a specific server using the activationAttributes
argument and provide in it a UrlAttribute() to the uri of
your service.

http://msdn.microsoft.com/library/default.asp?
url=/library/en-
us/cpref/html/frlrfSystemActivatorClassCreateInstanceTopic.
asp has an example of this. For reference, they are
connecting to "http://localhost:9000/MySampleService".

[quoted text, click to view]
sharipastore NO[at]SPAM yahoo.com
8/21/2003 7:48:51 AM
Here is my code. The problem I'm having is that I'm not trying to
register objects that inherit from MarshalByRefObject. The object is
an interface to receive remoting events from the server. The
CreateInstance doesn't work for interfaces and I'm not sure how else I
can get events to work.

private IBroadcaster[] _senderBroadcaster;
private BroadcastEventWrapper _senderEventWrapper;


string[] serverNames = new string[] { "localhost", "othermachine" };

_senderEventWrapper = new BroadcastEventWrapper();
_senderEventWrapper.FilesSentLocal += new
FilesSentHandler(OnFilesSent);
for( int ii = 0; ii < 2; ii++ )
{
string Url = "tcp:\\" + serverNames[ii] +
":8086\\SenderBroadcaster";
System.Runtime.Remoting.Activation.UrlAttribute urlAttr =
new System.Runtime.Remoting.Activation.UrlAttribute(Url);

object [] act = {urlAttr};
ObjectHandle objectHandle = null;
objectHandle = (ObjectHandle)Activator.GetObject(typeof(IBroadcaster),
Url);
_senderBroadcaster[ii] = (IBroadcaster)objectHandle.Unwrap();
_senderBroadcaster[ii].FilesSent +=
new FilesSentHandler(_senderEventWrapper.LocallyHandleFilesSent);
}

Thanks,

Shari


[quoted text, click to view]
SEWilson
8/22/2003 1:52:56 AM

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

http://www.genuinechannels.com/Content.aspx?id=27&type=1

http://www.ingorammer.com/RemotingFAQ/USEINTERFACESWITHCONFIGFILES.htm
l

All remoted objects MUST inherit from MarshalByRefObject if you want
to do things like use one of their methods as an event handler, even
though you use interfaces, the underlying object must be MBR.
Otherwise you either get an exception or a serialized instance when
you try to pass it over the network, given that all else is correct
anyway.

Is this your own framework or something 3rd party? (referring to
"IBroadcaster")

"Url" looks incorrect, if not for the "\" instead of "//" and the
inclusion of a servicename ("/SenderBroadcaster") it would be fine as
a callsite for UrlAttribute().

Are you sure you have a "wellknown" service object? You're using
GetObject not CreateInstance, and CreateInstance isn't something you
use for wellknown objects (SAOs).

:) "act" doesn't do anything, if the only thing you want is to get
messaging working consider looking at that first Url I provided. If
you need more knowledge on how to use interfaces to create objects
(and thus sample code to compare against the code you posted) see
that second Url. Also be aware that NAT and Firewall can affect your
ability to register objects for events. If you're using wellknown
objects note that I think they recycle every 5 minutes or so (dont
quote me) and also have async/MT contention problems, unless these
issues were addressed in the 1.1 release.

Hope that helps
- Shaun



[quoted text, click to view]

-----BEGIN PGP SIGNATURE-----
Version: PGP 8.0.2

iQA/AwUBP0XZ5qZcqAh+utlREQK1XACgtQY1zdtb/2MqDoNgySCloLnkA0YAoMW4
tqYf7EsYl09dm+7k3I/LnOfe
=Kqf4
-----END PGP SIGNATURE-----

AddThis Social Bookmark Button