繁体   English   中英

带有消息的偶发WCF服务激活错误 - 访问IIS元数据库时发生错误

[英]Sporadic WCF Service activation error with message - An error occurred while accessing the IIS Metabase

我正在讨论一个项目,早些时候我只托管单个WCF服务。 一切都习以为常。 稍后,作为增强功能的一部分,我们将两个WCF服务添加到具有不同接口和不同SVC文件的同一项目中。 所有三个服务共享相同的web.config,它定义了三个端点(对应于每个服务)。

我的项目的WCF服务作为单独的网站托管,具有自己的应用程序池和端口号。 我的所有三个服务共享相同的应用程序池。

有了这个设置,当我多次将应用程序部署到测试服务器时,我得到零星错误,如下所示,服务停止工作。 在这三个服务中,一次一个或两个给出这个错误,其他的继续工作。

    System.ServiceModel.ServiceHostingEnvironment+HostingManager/4032828
    System.ServiceModel.ServiceActivationException: The service '...svc' cannot be activated due to an exception during compilation.  The exception message is: An error occurred while accessing the IIS Metabase.. ---> 

    System.Runtime.InteropServices.COMException: An error occurred while accessing the IIS Metabase.
   at System.ServiceModel.Activation.MetabaseReader..ctor

我为webservice启用了svclogs,在那里我看到了类似的东西

......
AppDomain unloading
To: construct ServiceHost 'myservice1'
From: construct ServiceHost 'myservice1'
To: Open ServiceHost 'myservice1'
From: ServiceHost 'myservice1'
ASP.NET hosted service activated
**Wrote To Eventlog**     << Exception at this point for myservice2.

我试过这个选项,但它没有帮助。 我也在网上搜索,但没有找到任何其他可以提供帮助的解决方案。

我在测试服务器上安装了IIS6。

任何帮助将不胜感激。

更新:


我观察到了一种模式。 空闲时间之后,无论哪个服务首先被正确激活,其他服务都会失败。 另外,要添加到Port部分,我们特别提到将运行此服务的端口。 对于我的应用程序说端口号是25000,那么此服务器上没有其他应用程序共享此端口号,只有我的应用程序。 因此,如果有多个服务,那么他们正在共享端口,但同样的设置是针对具有多个SVC服务的其他项目,并且没有人遇到过这个问题(据我所知)。

更新2:下面是配置文件。 我输入了配置文件但尝试尽可能准确。 (请忽略区分大小写的事情)

<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="MyBinding">
                <security mode="TransportCredentialOnly">
                    <transport clientCredentialType="Basic" proxyCredentialType="Basic" realm="prod.xxx.net" />
                    <message clientCredentialType="UserName" algorithmSuite="Default"/>
                </security>
            </binding>
        </basicHttpBinding>
    </bindings>

    <behaviours>
        <serviceBehaviours>
            <behaviour name="firstServiceBehaviour">
                <serviceMetadata httpGetEnabled="true" />
                <serviceDebug includeExceptionDetailInFaults="true" />
                <serviceCredentials>
                    <clientCertificate>
                        <authentication mapClientCertificateToWindowsAccount="true" />
                    </clientCertificate>
                </serviceCredentials>
                <dataContractSerializer maxItemsInObjectGraph="2147483646" />
            </behaviour>

<behaviours>
    <serviceBehaviours>
        <behaviour name="secondServiceBehaviour">
            <serviceMetadata httpGetEnabled="true" />
            <serviceDebug includeExceptionDetailInFaults="true" />
            <serviceCredentials>
                <clientCertificate>
                    <authentication mapClientCertificateToWindowsAccount="true" />
                </clientCertificate>
            </serviceCredentials>
        </behaviour>

<behaviours>
    <serviceBehaviours>
        <behaviour name="thirdServiceBehaviour">
            <serviceMetadata httpGetEnabled="true" />
            <serviceDebug includeExceptionDetailInFaults="true" />
            <serviceCredentials>
                <clientCertificate>
                    <authentication mapClientCertificateToWindowsAccount="true" />
                </clientCertificate>
            </serviceCredentials>
            <dataContractSerializer maxItemsInObjectGraph="2147483646" />
        </behaviour>

    <services>
        <service behaviourConfiguration="firstServiceBehaviour" name="...">
            <endpoint address="" binding="basicHttpBinding" bindingConfiguration="MyBinding" name="firstServiceEndPoint" contract="IfirstServiceContract" />
        </service>

        <service behaviourConfiguration="secondServiceBehaviour" name="...">
            <endpoint address="" binding="basicHttpBinding" bindingConfiguration="MyBinding" name="secondServiceEndPoint" contract="IsecondServiceContract" />
        </service>

        <service behaviourConfiguration="thirdServiceBehaviour" name="...">
            <endpoint address="" binding="basicHttpBinding" bindingConfiguration="MyBinding"
name="thirdServiceEndPoint" contract="IthirdServiceContract" />
        </service>
    </services>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</System.ServiceModel>

我不会说这是完整的答案,但这有助于解决我们的问题。 我仍然想知道问题的实际原因的原因/解决方案。 我提到这项工作,因为这可能有助于某人暂时解决他们的问题以及可能面临类似问题的人。

正如我所提到的那样,只有在应用程序闲置一段时间后才会出现问题。 在这种情况下,IIS正在关闭(卸载)应用程序的AppDomain(这是来自SVC Logs)。

因此,我们创建了一个简单的控制台应用程序,每隔5-10分钟就会触及我们应用程序的所有服务,并且不会让AppDomain关闭。 有一种替代方法可以实现这一点 - 将IIS配置设置为不卸载AppDomain(对于我们来说,这对共享基础架构来说不太可行)。 这有助于我们完成测试。

然后,当我们转向负载均衡的环境(测试环境接近生产)时,我们突然停止了解问题,通过一些分析,我们发现Load-Balancer本身正在ping这些服务,以确保它们已启动,并且因为这些服务的App域从未卸载过。

所以,现在我们可以说我们没有在负载均衡的环境中得到这个问题,但问题仍然存在,为什么它甚至发生(对于非负载平衡环境)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM