accessing properties of remote objects

J

Joel Lyons

I have a remote object with a public property (see code below). A client
can use this property to receive a ref to another remote object and use it's
properties.
This works great over a LAN, but over the internet, when the client tries to
use this second object by calling a property or method, the call hangs for
about 30 seconds then throws the following exception:
"A connection attempt failed because the connected party did not properly
respond after a period of time, or established connection failed because
connected host has failed to respond"

When I create the initial connection to the remote service
(MyRemoteService), it communicates via the ip address and port I specified
in the URI passed to RemotingServices.Connect. But when I then retrieve a
ref to MyRemoteObject and call its methods, what ip address/port is used for
that network communication? I'm guessing it's using another port that is
not open thru a firewall.

---------code-------------------------------------
SERVER:
public class MyRemoteObject : MarshalByRefObject
{
public int MyProperty {
get { return 5; }
}
}

public class MyRemoteService : MarshalByRefObject
{
public MyRemoteObject RemoteObject {
get { return new MyRemoteObject(); }
}
}

CLIENT:
public class MyClientApp {
public Run() {
MyRemoteService remSvc =
(MyRemoteService)RemotingServices.Connect(typeof(MyRemoteService),
String.Format("tcp://{0}:{1}/MyRemoteService", IPAddress, Port));
MyRemoteObject remObj = remSvc.RemoteObject;
int remProp = remObj.MyProperty; //this hangs, then throws
exception
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top