通过 TCP 远程连接 [英] Remoting connection over TCP
问题描述
我已经构建了远程处理服务器和客户端.服务器设置如下:
I've got a remoting server and client built. The server is set up 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 );
客户端设置如下:
ChannelServices.RegisterChannel( new TcpChannel( 0 ), false );
m_Controller = (Controller)RemotingServices.Connect( typeof( Controller ),
"tcp://" + ip + ":2594/Controller" );
当我尝试从 IP 指定为localhost"的同一台计算机连接到服务器时,它连接正常.但是,当我尝试从远程计算机而不是 LAN 进行连接时,鉴于服务器的 IP 地址,经过漫长的等待后,我在客户端上收到以下异常:
When I try to connect to the server from the same computer with the IP specified as 'localhost,' it connects fine. However, when I try to connect from a remote computer, not on the LAN, given the server's IP address, I receive the following exception on the client after a long wait:
A connection attempt failed because the connected party did not properly
respond after a period of time
我该如何解决这个问题?我确定这是一个配置问题,因为端口在服务器上正确转发并且没有防火墙处于活动状态.
How can I resolve this? I'm sure it's a configuration problem because the ports are forwarded properly on the server and there is no firewall active.
谢谢
推荐答案
这个问题已经有一个月了,但仍然如此:
This question is a month old, but none the less:
嗅探服务器(最好也包括客户端)上的流量应该能让您更深入地了解正在发生的事情.
Sniffing the traffic on the server (and preferably, on the client as well) should give you more insight as to what's going on.
对于这项工作,我推荐 Packetyzer,这是一款非常友好的 Windows 数据包嗅探器.
For the job I recommend Packetyzer, a very friendly packet sniffer for Windows.
这篇关于通过 TCP 远程连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!