远程对象和远程连接 [英] Remoting objects and remote connections
问题描述
我将 .NET 远程处理用于一些简单的基于观察者的 IPC.我遇到了两个问题:
I'm using .NET remoting for some simple observer-based IPC. I've been having two problems:
- 如果我几分钟内没有从客户端对远程对象进行任何调用,当我尝试调用时会抛出一个错误,指出连接已断开.我怎样才能让它保持活力?
我似乎无法通过 TCP 接受来自其他计算机的客户端.我正在使用这样配置的 TcpChannel:
- If I don't make any calls from the client on a remote object for a few minutes, an error is thrown when I do try to call, specifying that the connection has been dropped. How can I keep this alive?
I can't seem to accept clients from other computers over TCP. I'm using a TcpChannel configured as such:
BinaryServerFormatterSinkProvider serverProv = new
BinaryServerFormatterSinkProvider();
serverProv.TypeFilterLevel = TypeFilterLevel.Full;
BinaryClientFormatterSinkProvider clientProv = new
BinaryClientFormatterSinkProvider();
IDictionary props = new Hashtable();
props["port"] = port;
TcpChannel channel = new TcpChannel( props, clientProv, serverProv );
ChannelServices.RegisterChannel( channel, false );
RemotingConfiguration.RegisterWellKnownServiceType( typeof( Controller ),
"Controller", WellKnownObjectMode.Singleton );
当客户端应用程序尝试连接时 ( m_Controller = (Controller)RemotingServices.Connect( typeof( Controller ), "tcp://" + ip + ":2594/Controller" ) )
,它总是超时.我不在防火墙后面,我的端口被正确转发.我可以将此端口用于基于套接字的应用程序,但由于某种原因不能用于远程处理.请帮忙!
And when a client app tries to connect ( m_Controller = (Controller)RemotingServices.Connect( typeof( Controller ), "tcp://" + ip + ":2594/Controller" ) )
, it always times out. I am not behind a firewall and my ports are forwarded properly. I can use this port for socket-based apps but not for remoting for some reason. Please help!
推荐答案
- 您是否初始化了 Controller 对象的生命周期?请参阅 http://www.diranieh.com/NETRemoting/InDepthRemoting.htm.
- 在此处查看我的答案:通过 TCP 远程连接.立>
这篇关于远程对象和远程连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!