【问题标题】:How to configure a WCF service for a load balancer如何为负载均衡器配置 WCF 服务
【发布时间】:2010-11-30 16:05:39
【问题描述】:

如何为负载均衡器配置 WCF 服务并指定端点

【问题讨论】:

  • 您是在进行“正常”负载平衡(即将请求转发到不同的服务器),还是使用负载平衡器进行 SSL 卸载?

标签: wcf


【解决方案1】:

您可以尝试编写custom service host factory,它将使用负载均衡器的 url 作为基地址:

public class CustomServiceHostFactory : ServiceHostFactory
{
    protected override ServiceHost CreateServiceHost(
        Type serviceType, Uri[] baseAddresses)
    {
        Uri uri = null;
        if (baseAddresses.Length < 2)
        {
            uri = baseAddresses[0];
        }
        else
        {
            // TODO: You need to choose the load balancer's url here:
            uri = baseAddresses[????];
        }
        return base.CreateServiceHost(serviceType, new Uri[] { uri });
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-04-19
    • 2013-04-11
    • 1970-01-01
    • 1970-01-01
    • 2017-02-12
    • 2013-08-26
    • 2010-09-16
    相关资源
    最近更新 更多