远程对象和远程连接 [英] Remoting objects and remote connections

查看:34
本文介绍了远程对象和远程连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm using .NET remoting for some simple observer-based IPC. I've been having two problems:

  1. 如果我几分钟内没有从客户端对远程对象进行任何调用,当我尝试调用时会抛出一个错误,指出连接已断开.我怎样才能让它保持活力?
  2. 我似乎无法通过 TCP 接受来自其他计算机的客户端.我正在使用这样配置的 TcpChannel:

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

当客户端应用程序尝试连接时 ( 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!

推荐答案

  1. 您是否初始化了 Controller 对象的生命周期?请参阅 http://www.diranieh.com/NETRemoting/InDepthRemoting.htm.
  2. 在此处查看我的答案:通过 TCP 远程连接.立>

这篇关于远程对象和远程连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆