Remoting objects and remote connections

断了今生、忘了曾经 提交于 2019-12-11 06:59:15

问题


I'm using .NET remoting for some simple observer-based 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. 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 );
    

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!


回答1:


  1. Have you initialized the Controller object's lifetime? See http://www.diranieh.com/NETRemoting/InDepthRemoting.htm.
  2. See my answer in here: Remoting connection over TCP.


来源:https://stackoverflow.com/questions/719425/remoting-objects-and-remote-connections

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!