【问题标题】:Remoting objects and remote connections远程对象和远程连接
【发布时间】:2009-04-05 18:26:51
【问题描述】:

我正在为一些简单的基于观察者的 IPC 使用 .NET 远程处理。我遇到了两个问题:

  1. 如果我在几分钟内没有从客户端对远程对象进行任何调用,当我尝试调用时会引发错误,指出连接已断开。我怎样才能让它活着?
  2. 我似乎无法通过 TCP 接受来自其他计算机的客户端。我正在使用这样配置的 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 );
    

当客户端应用程序尝试连接 ( m_Controller = (Controller)RemotingServices.Connect( typeof( Controller ), "tcp://" + ip + ":2594/Controller" ) ) 时,它总是超时。我不在防火墙后面,并且我的端口已正确转发。我可以将此端口用于基于套接字的应用程序,但由于某种原因不能用于远程处理。请帮忙!

【问题讨论】:

  • 请注意,使用 localhost 作为 IP 可以正常工作。它只是从一台搞砸的远程计算机连接。

标签: c# remoting


【解决方案1】:
  1. 您是否初始化了控制器对象的生命周期?见http://www.diranieh.com/NETRemoting/InDepthRemoting.htm
  2. 在这里查看我的答案:Remoting connection over TCP

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-09-21
    • 2010-10-24
    • 2016-07-13
    • 1970-01-01
    • 1970-01-01
    • 2011-03-23
    • 2012-07-08
    相关资源
    最近更新 更多