简体   繁体   English

远程对象和远程连接

[英]Remoting objects and remote connections

I'm using .NET remoting for some simple observer-based IPC. 我正在使用.NET远程处理一些基于观察者的简单IPC。 I've been having two problems: 我一直遇到两个问题:

  1. 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? 我怎样才能保持下去?
  2. I can't seem to accept clients from other computers over TCP. 我似乎无法通过TCP从其他计算机接受客户端。 I'm using a TcpChannel configured as such: 我正在使用这样配置的TcpChannel:

     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 ); 

And when a client app tries to connect ( m_Controller = (Controller)RemotingServices.Connect( typeof( Controller ), "tcp://" + ip + ":2594/Controller" ) ) , it always times out. 当客户端应用尝试连接时( m_Controller = (Controller)RemotingServices.Connect( typeof( Controller ), "tcp://" + ip + ":2594/Controller" ) ) ,它总是超时。 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! 请帮忙!

  1. Have you initialized the Controller object's lifetime? 您是否已初始化Controller对象的生存期? See http://www.diranieh.com/NETRemoting/InDepthRemoting.htm . 请参阅http://www.diranieh.com/NETRemoting/InDepthRemoting.htm
  2. See my answer in here: Remoting connection over TCP . 在这里查看我的答案: 通过TCP远程连接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM