【发布时间】:2014-08-19 14:10:36
【问题描述】:
我有一个客户端和一个主机应用程序。客户端可以发送消息并返回回调消息。
我使用此代码在客户端创建双工通道:
proxy = DuplexChannelFactory<IMonitor>.CreateChannel(new InstanceContext(this), new NetTcpBinding(SecurityMode.None), new EndpointAddress(endpoint));
在主机应用程序上,我自行托管服务:
using (ServiceHost host = new ServiceHost(typeof(MonitorImpl.Monitor), new Uri(uri)))
{
host.Open();
Console.WriteLine("Service is hosted, has the following endpoints.");
host.Description.Endpoints.ToList().ForEach(end => Console.WriteLine(end.Address));
return Console.ReadLine();
}
您可能已经注意到,我有一个名为:MonitorImpl 的项目,其中包含 Monitor 类。这个类包含了我用来调用服务的方法和回调方法的代码。
该程序在本地运行,如果我在托管主机应用程序的计算机上打开端口,它也可以在两台不同的计算机上运行(在同一网络中)。
我的问题是:我怎样才能在 2 台不同的计算机上(通过互联网)进行这项工作,而不必更改托管应用程序的计算机上的防火墙?我是否需要更改绑定到其他东西的类型,如果是这样......到什么?我是否需要更改创建双工通道的方式或位置?还有什么?
【问题讨论】:
标签: c# wcf firewall nettcpbinding duplex