为什么我不能通过net.tcp连接到WCF服务,但是可以通过http连接?

为什么我不能通过net.tcp连接到WCF服务,但是可以通过http连接?

问题描述:

我在带有ServiceHostFactory的IIS上运行了WCF服务. WSHttpBinding可以正常运行,但是由于速度和所有内容都在同一网络(没有防火墙)中,我想使用NetTcpBinding来加快速度.

I have a WCF service running on the IIS with a ServiceHostFactory. It's running fine with the WSHttpBinding but because of the speed and everything being on the same network (no firewalls) i want to speed up things a bit using the NetTcpBinding instead.

当我尝试这样做时,出现此错误:

When i try to do that i get this error:

无法连接到net.tcp://zzz.xxx.yyy/MyService.svc.连接尝试持续时间为00:00:01.0464395. TCP错误代码10061:无法建立连接,因为目标计算机主动拒绝了它x.x.x.x:808.

Could not connect to net.tcp://zzz.xxx.yyy/MyService.svc. The connection attempt lasted for a time span of 00:00:01.0464395. TCP error code 10061: No connection could be made because the target machine actively refused it x.x.x.x:808.

我正在使用SecurityMode.None只是为了确保这不会给我带来麻烦,我还尝试了两种不同的尝试:

I'm using SecurityMode.None just to make sure that is not screwing me also i tried either of these on two different tries:

binding.Security.Message.ClientCredentialType = MessageCredentialType.None;
binding.Security.Message.ClientCredentialType = TcpClientCredentialType.Windows;,

我还应该指出,我从一个服务调用中提取了相当数量的数据,因此我也将这些数据(都放在http和tcp尝试上-将maxMessageSize设置为1000000)

Also i should point out, that i'm pulling quite a lof of data from one of the service calls, so i also put these (both on the http and the tcp attempts - setting maxMessageSize to 1000000)

binding.MaxReceivedMessageSize = maxMessageSize;
binding.ReaderQuotas.MaxArrayLength = maxMessageSize;

让它正常工作应该很容易,所以我想念什么?

It should be pretty easy getting it to work, so what am I missing?

更新:我将TCP端口808添加到网站标识中,然后重试.现在我收到此错误:

UPDATE: I added the TCP port 808 to the website identity and tried again. Now i get this error:

您试图为不支持.Net Framing的服务创建通道.您可能会遇到HTTP端点.

You have tried to create a channel to a service that does not support .Net Framing. It is possible that you are encountering an HTTP endpoint.

查看

Check out this post on enabling non-HTTP bindings in IIS 7.0. By default, you have to explicitly enable net.tcp in IIS 7.0.

希望这会有所帮助.

更新:

看到您的评论-不幸的是,IIS 6.0不支持net.tcp.查看此链接,其中详细介绍了各种主机支持的WCF绑定(包括自托管,WAS和IIS).看起来只有HTTP绑定才能在IIS 6.0中工作.

Saw your comment - unfortunately, net.tcp is not supported in IIS 6.0. Check out this link which details the supported WCF bindings for various hosts (including self-hosting, WAS, and IIS). Looks like only HTTP bindings work in IIS 6.0.