Remoting Factory Problems
- From: gegnal@xxxxxxxxx
- Date: 7 May 2007 14:42:03 -0700
I'm trying to have a singleton server return a new session upon client
request. I thought I was using the traditional factory pattern, but
it is having problems connecting to the new session after the sever
creates it. The code has no trouble remoting to the server; the
sessions are the problem. The client code returns the 'connection
actively refused by target' exception.
Since the server and all of its new sessions exist on the same
channel, and since I can telnet into it, I know the connection is
alive. Also, the code works when client/server are running on one
machine.
Any help appreciated
----------------------------------------------------------------------------------------------------
A simplified code extraction:
public class Session : MarshalByRefObject
{
in data;
public Session(int d;) { data = d; }
}
SERVER
public class Server() : MarshalByRefObject
{
public Server()
{
channel = new TcpChannel(connectionConfig.port);
ChannelServices.RegisterChannel(channel, false);
RemotingConfiguration.RegisterWellKnownServiceType(
typeof(Server), connectionConfig.name,
WellKnownObjectMode.Singleton);
}
public ISession CreateSession() {return new Session(int
data);}
}
CLIENT
public class Client()
{
//setup etc are omitted for brevity
public void Connect()
{
IServer sessionMgr = (IServer)Activator.GetObject(
typeof(IServer), String.Format("tcp://{0}:{1}/{2}",
serverAddress,
connectionConfig.port,
connectionConfig.name));
Session s = sessionMgr.CreateSession(); // this works
nicely, showing the server is connected
int d = s.GetData(); // THIS SAYS TARGET ACTIVELY
REFUSED CONNECTION???
}
.
- Prev by Date: Re: Deploying remote architectute host by windows service.
- Next by Date: Help with Remoting basics
- Previous by thread: Deploying remote architectute host by windows service.
- Next by thread: Help with Remoting basics
- Index(es):
Relevant Pages
|