We have a strange problem with .NET Remoting. Basically, we have a server that registers two TcpChannels using ChannelServices.RegisterChannel() :
- One is listening on port 50,000
- Another is listening on port 15000.
Then we have a client that registers TcpChannel to be able to communicate with the server. We retrieve the object from the server by calling Activator.GetObject() with a URI
"TCP: // ServerIP: 50000 / object_name"
and it works great, the client connects to the server on port 50000 and receives the object.
However, when we start calling methods on this object, the connection to the channel on port 50000 is dropped, and a new connection to the channel on port 15000 is automatically established. This creates a real problem for us, because we do not want traffic on port 15000, because this channel cannot be bound to the same network adapter as port 50000 on the server, or this port cannot be opened in the firewall, which causes remote calls to fail naturally.
This is very strange for us, because the client does not know in our code that another channel exists on the server on port 15000 or what IP address it listens to, but it tries to connect to it.
Any help on this is greatly appreciated.
Thanks Casper
This is the code that installs one of the server channels, usually on port 50000:
IDictionary props = new Hashtable(); props["port"] = m_tcpPort; props["name"] = String.Empty; BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider(); serverProvider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; BinaryClientFormatterSinkProvider clientProvider = new BinaryClientFormatterSinkProvider(); m_tcpChannel = new TcpServerChannel( props, serverProvider ); ChannelServices.RegisterChannel( m_tcpChannel, false ); m_wellKnownObjRef = RemotingServices.Marshal( this, "Server@" + m_tcpPort.ToString() );
This is the code that sets up another server channel, usually on port 15000:
IDictionary props = new Hashtable(); props["name"] = String.Empty; props["port"] = ip.Port; props["bindTo"] = ip.Address.ToString(); props["timeout"] = REMOTING_TIMEOUT; // Timeout to prevent hung remoting calls. if (!String.IsNullOrEmpty( machineName )) { props["machineName"] = machineName; } BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider(); serverProvider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; BinaryClientFormatterSinkProvider clientProvider = new BinaryClientFormatterSinkProvider(); m_channel = new TcpChannel( props, clientProvider, serverProvider ); ChannelServices.RegisterChannel( m_channel, false ); m_objRef = RemotingServices.Marshal( this, QueueName ); // Queuename is a GUID.
This is the code in the client that connects to the first server channel, which is usually located on port 50000:
IDictionary props = new Hashtable(); props["port"] = 0; RemotingConfiguration.CustomErrorsMode = CustomErrorsModes.Off; BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider(); serverProvider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; BinaryClientFormatterSinkProvider clientProvider = new BinaryClientFormatterSinkProvider(); m_tcpChannel = new TcpClientChannel(props, clientProvider); ChannelServices.RegisterChannel(m_tcpChannel, false ); string address = "tcp://" + profile.RemoteIP + ":" + profile.RemoteTCP; m_server = (Kernel)Activator.GetObject(typeof(Server), address + "/Server@" + port);