WCF:TCP.NET 上的多个绑定

发布于 2024-11-10 04:36:10 字数 1233 浏览 0 评论 0原文

我正在尝试在 IIS 7.5 下设置一个具有多个 tcp.net 绑定的网站。

由于该服务位于负载均衡器后面,因此我需要该服务的多个端点:

log.o1881.no/log/service.svc

log.core1.o1881.no/log/service.svc

当我在 web 中配置时,这适用于 http 绑定.config:

<system.serviceModel>
  <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>

将以下 tcp.net 绑定添加到站点时,会出现以下错误消息:

808:log.o1881.no

808:log.core1.o1881.no

“/Log”应用程序中的服务器错误。

该集合已包含具有方案 net.tcp 的地址。该集合中的每个方案最多可以有一个地址。如果您的服务托管在 IIS 中,您可以通过将“system.serviceModel/serviceHostingEnvironment/multipleSiteBindingsEnabled”设置为 true 或指定“system.serviceModel/serviceHostingEnvironment/baseAddressPrefixFilters”来解决该问题。 参数名称:项目

我也尝试将其添加到 web.config:

<serviceHostingEnvironment multipleSiteBindingsEnabled="true">
  <baseAddressPrefixFilters>
    <add prefix="net.tcp://log.o1881.no:808/log" />
    <add prefix="net.tcp://log.core1.o1881.no:808/log" />
  </baseAddressPrefixFilters>
</serviceHostingEnvironment>

但这不起作用。

由于该服务将部署在多个服务器上,因此我非常希望能够通过配置和 IIS 设置(而不是代码)来完成这项工作。

这是否可以做到,或者是否有其他方法来处理这种情况(由于负载平衡,http 和 net.tcp 上有多个绑定名称)?

I am trying to set up a website under IIS 7.5 with multiple tcp.net bindings.

Since the service is behind a loadbalancer I need multiple endpoints for the service:

log.o1881.no/log/service.svc

log.core1.o1881.no/log/service.svc

this works for the http bindings when I configure in web.config:

<system.serviceModel>
  <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>

The following error message appears when the following tcp.net bindings are added to the site:

808:log.o1881.no

808:log.core1.o1881.no

Server Error in '/Log' Application.

This collection already contains an address with scheme net.tcp. There can be at most one address per scheme in this collection. If your service is being hosted in IIS you can fix the problem by setting 'system.serviceModel/serviceHostingEnvironment/multipleSiteBindingsEnabled' to true or specifying 'system.serviceModel/serviceHostingEnvironment/baseAddressPrefixFilters'.
Parameter name: item

I also tried to add this to web.config:

<serviceHostingEnvironment multipleSiteBindingsEnabled="true">
  <baseAddressPrefixFilters>
    <add prefix="net.tcp://log.o1881.no:808/log" />
    <add prefix="net.tcp://log.core1.o1881.no:808/log" />
  </baseAddressPrefixFilters>
</serviceHostingEnvironment>

This does however not work.

Since the service will be deployed on multiple servers, I would very much like to be able to make this work through configuration and IIS setup, not in code.

Is this possible to do, or is there another way to handle this scenario (multiple binding names on http and net.tcp, due to loadbalancing)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

宛菡 2024-11-17 04:36:10

根据文档,使用multipleSiteBindingsEnabled告诉 WCF 忽略任何

“当使用此设置启用多个站点绑定时,对于 HTTP 和非 HTTP 协议,任何 baseAddressPrefixFilters 设置都将被忽略。”

因此,此配置自相矛盾,您指定地址前缀并同时指示 WCF忽略它们,因为您已指定multipleSiteBindingsEnabled

<serviceHostingEnvironment multipleSiteBindingsEnabled="true">
  <baseAddressPrefixFilters>
    <add prefix="net.tcp://log.o1881.no:808/log" />
    <add prefix="net.tcp://log.core1.o1881.no:808/log" />
  </baseAddressPrefixFilters>
</serviceHostingEnvironment>

我认为 multipleSiteBindingsEnabled 最适合您只对使用 HTTP 方案感兴趣的场景。

否则,请勿使用它,实际上您可以在同一 IIS 站点/应用程序层次结构中的不同端口上拥有多个 tcp.net 绑定

<serviceHostingEnvironment>
  <baseAddressPrefixFilters>
    <add prefix="net.tcp://log.o1881.no:808/log" />
    <add prefix="net.tcp://log.core1.o1881.no:808/log" />
  </baseAddressPrefixFilters>
</serviceHostingEnvironment>

希望这对其他人有帮助:)

According to the documentation the use of multipleSiteBindingsEnabled tells WCF to ignore any <baseAddressPrefixFilters>.

"Any baseAddressPrefixFilters settings are ignored, for both HTTP and non-HTTP protocols, when multiple site bindings are enabled using this setting."

So this configuration contradicts itself, you are specifying address prefixes and simultaneously instructing WCF to ignore them since you are have multipleSiteBindingsEnabled specified.

<serviceHostingEnvironment multipleSiteBindingsEnabled="true">
  <baseAddressPrefixFilters>
    <add prefix="net.tcp://log.o1881.no:808/log" />
    <add prefix="net.tcp://log.core1.o1881.no:808/log" />
  </baseAddressPrefixFilters>
</serviceHostingEnvironment>

I think the multipleSiteBindingsEnabled is best for scenarios where you are only interested in using HTTP schemes.

Otherwise don't use it and you can in fact have multiple tcp.net bindings on different ports in the same IIS Site/App hierarchy.

<serviceHostingEnvironment>
  <baseAddressPrefixFilters>
    <add prefix="net.tcp://log.o1881.no:808/log" />
    <add prefix="net.tcp://log.core1.o1881.no:808/log" />
  </baseAddressPrefixFilters>
</serviceHostingEnvironment>

Hope this helps others :)

神妖 2024-11-17 04:36:10

据我所知,这是不可能的:

如果有人找到此解决方案,请分享...

For as far as I've found, this is impossible:

If anyone finds a solution for this, please share...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文