我在 IIS8 中有一个 WCF 服务主机,我想使用 net.tcp 绑定。
我有这个配置:
网络配置:
<service behaviorConfiguration="MyBehavior"
name="DecryptService.EmailCenterDecryptTCP">
<host>
<baseAddresses>
<add baseAddress="net.tcp://XX.XX.XX.XX:808/VirtualFolder/Service.svc" />
</baseAddresses>
</host>
<endpoint address=""
binding="netTcpBinding"
bindingConfiguration="portSharingBinding"
name="MyServiceEndpoint"
contract="ServiceNamespace.IService">
</endpoint>
<endpoint address="mextcp"
binding="mexHttpBinding"
bindingConfiguration=""
name="MyServiceMexTcpBidingEndpoint"
contract="IMetadataExchange" />
</service>
当我尝试在与 IIS8 相同的机器上使用该服务时,以下配置工作正常:
<client>
<endpoint address="net.tcp://YY.YY.YY.YY:808/VirtualFolder/Service.svc"
binding="netTcpBinding" bindingConfiguration="MyServiceEndpoint"
contract="ServiceReference1.IService" name="MyServiceEndpoint" />
</client>
YY.YY.YY.YY 是机器的本地 IP,但是当我尝试在另一台机器上使用服务时,将 YY.YY.YY.YY 更改为运行 IIS8 的机器的外部 IP (ZZ.ZZ.ZZ.ZZ)我收到以下错误:
There was no endpoint listening at net.tcp://ZZ.ZZ.ZZ.ZZ/VirtualFolder/Service.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
有任何想法吗?感谢和抱歉我的英语不好
编辑:
我制作了一个运行 ServiceHost 替换 IIS 的控制台应用程序,并且使用此配置它可以在 Internet 上运行
var svh = new ServiceHost(typeof (Service));
svh.AddServiceEndpoint(typeof (ServiceNamespace.IService), new NetTcpBinding(SecurityMode.None), "net.tcp://serverLocalIp:808");
svh.Open();
Console.WriteLine("SERVER - Running...");
stopFlag.WaitOne();
Console.WriteLine("SERVER - Shutting down...");
svh.Close();
Console.WriteLine("SERVER - Shut down!");
知道通过 Internet 运行相同服务的 IIS 有什么问题吗?本地工作。谢谢