Ser*_*edo 5 c# wcf net.tcp iis-8
我在 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>
Run Code Online (Sandbox Code Playgroud)
当我尝试使用以下配置在与 IIS8 相同的机器上使用该服务时工作正常:
<client>
<endpoint address="net.tcp://YY.YY.YY.YY:808/VirtualFolder/Service.svc"
binding="netTcpBinding" bindingConfiguration="MyServiceEndpoint"
contract="ServiceReference1.IService" name="MyServiceEndpoint" />
</client>
Run Code Online (Sandbox Code Playgroud)
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.
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?感谢并抱歉我的英语不好
编辑:
我制作了一个运行 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!");
Run Code Online (Sandbox Code Playgroud)
知道通过 Internet 运行相同服务的 IIS 有什么问题吗?本地工作。谢谢
您还需要设置 IIS 以接收 Net.TCP 连接。
在Advanced Settings你的 IIS 应用程序下,然后在Enabled Protocols确保你有http,net.tcp注意没有空间,如果你有空间它会失败。
http://blogs.msdn.com/b/swiss_dpe_team/archive/2008/02/08/iis-7-support-for-non-http-protocols.aspx
如果有一天您突然收到此错误,这与另一个进程劫持 net.tcp 端口有关。就我而言,它是端口 808。这是我在大约 3 天后弄清楚的方法——这就是我现在所做的,谷歌并试图找出其他人的问题而不是做我自己的工作。
无论如何:
这是有道理的,因为其他一些进程已经在使用端口 808,因此它不可用于Net.TCP。
此时我有两个选择:
幸运的是,他们已经更新了驱动程序,所以我只是从这里下载并安装了它。
重新启动然后再次运行以下命令以确保 net.tcp 的端口可用: