应用程序池回收后,WCF服务不可用

时间:2012-09-09 14:04:24

标签: wcf web-services castle-windsor application-pool recycle

我正在使用一个网站,该网站使用托管在不同应用程序池中的WCF服务,每次WCF服务的应用程序池回收时,我在使用该网站时都会得到503:

[WebException: The remote server returned an error: (503) Server Unavailable.]
   System.Net.HttpWebRequest.GetResponse() +6440728
   System.ServiceModel.Channels.HttpChannelRequest.WaitForReply(TimeSpan timeout) +55

[ServerTooBusyException: The HTTP service located at http://cr.genesis.dev/Genesis/RepositoryService.svc is unavailable.  This could be because the service is too busy or because no endpoint was found listening at the specified address. Please ensure that the address is correct and try accessing the service again later.]
...

当我尝试直接在我的网络浏览器中访问该服务时,它第一次给我一个503,但之后它可以工作(可能是因为它导致应用程序启动?)我想知道为什么网站不是唤醒网络服务 - 即使我尝试多次加载页面,我仍然会得到一个503 ...

我正在使用Windsor WCF Integration,如果这有任何区别,使用LifestylePerWebRequest为我的客户端和LifestylePerThread为我的服务。

这是我对该服务的配置:

<system.serviceModel>
        <services>
            <service name="Genesis.Repository.Service.RepositoryService" behaviorConfiguration="repositoryServiceBehaviour">
                <host>
                    <baseAddresses>
                        <add baseAddress="http://cr.genesis.dev/Genesis/" />
                    </baseAddresses>
                </host>
                <endpoint name="basicHttpBinding"
                    address="RepositoryService.svc"
                    binding="basicHttpBinding"
                    contract="Genesis.Repository.Service.IRepositoryService" />
            </service>
        </services>
        <behaviors>
            <serviceBehaviors>
                <behavior name="repositoryServiceBehaviour">
                    <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
                    <serviceMetadata httpGetEnabled="true" />
                    <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
                    <serviceDebug includeExceptionDetailInFaults="false"/>
                </behavior>
            </serviceBehaviors>
        </behaviors>
        <serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true" />
    </system.serviceModel>

客户:

<system.serviceModel>
        <client>
            <endpoint name="basicHttpBinding"
                 address="http://cr.genesis.dev/Genesis/RepositoryService.svc"
                 binding="basicHttpBinding"
                 contract="Genesis.Repository.Service.IRepositoryService" />
        </client>
    </system.serviceModel>

任何建议都将不胜感激!

2 个答案:

答案 0 :(得分:1)

看起来我让它变得比它需要的更复杂 - 我得到了例外说它无法听取http://+:80这就是为什么我玩netsh权限的原因并让它听取/Genesis

事实证明我可以让它在/上进行监听并在向Windsor注册时指定.Hosted()告诉它让IIS托管它(这与我安装{{之前的确切方式相同) 1}}!)

经验教训,有时你只需要回到基础知识,事情就会按预期发挥作用!

答案 1 :(得分:0)

如果发现“(503)服务器不可用错误”,则首先检查服务器是否正在运行。为此,请转到IIS并检查网站的打开或关闭。