I was haivng a project in which earlier I was hosting only single WCF service. Everything used to work fine. Later, as part of enhancements we have added two more WCF services to the same project with different Interfaces and different SVC files. All three services share same web.config which define the three end points (corresponding to each service).
我正在讨论一个项目,早些时候我只托管单个WCF服务。一切都习以为常。稍后,作为增强功能的一部分,我们为具有不同接口和不同SVC文件的同一项目添加了两个WCF服务。所有三个服务共享相同的web.config,它定义了三个端点(对应于每个服务)。
WCF services for my project are hosted as separate website with its own App Pool and port number. All three of my services share the same App pool.
我的项目的WCF服务作为单独的网站托管,具有自己的应用程序池和端口号。我的所有三个服务共享相同的应用程序池。
With this setup when I am deploying application to test servers many times I am getting sporadic error as below and service stops working. Of the three service, one or two at a time gives this error other keeps on working.
有了这个设置,当我多次将应用程序部署到测试服务器时,我收到零星错误,如下所示,服务停止工作。在这三个服务中,一次一个或两个给出这个错误,其他的继续工作。
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
I enabled svclogs for the webservice and there I am seeing things like
我为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.
I have tried This options but it doesn't help. I have also searched on net but not finding any other solution that can help.
我试过这个选项,但它没有帮助。我也在网上搜索,但没有找到任何其他可以提供帮助的解决方案。
I am having IIS6 on the test servers.
我在测试服务器上安装了IIS6。
Any help would be greatly appreciated.
任何帮助将不胜感激。
UPDATE:
I have observed a pattern. After Idle time, whichever service is hit first gets activated properly, other ones fails. Also, to add to Port part, we are specifically mentioning port on which this service would be running. for my application say the port number is 25000, then no other application on this server is sharing this port number, only my application. So if there are multiple Services, then they are sharing the port, but again the same setup is there for other projects having multiple SVC services and none has ever experienced this issue (as far as I know).
我观察到了一种模式。空闲时间之后,无论哪个服务首先被正确激活,其他服务都会失败。此外,要添加到Port部分,我们特别提到将运行此服务的端口。对于我的应用程序说端口号是25000,那么此服务器上没有其他应用程序共享此端口号,只有我的应用程序。因此,如果有多个服务,那么他们正在共享端口,但同样的设置是针对具有多个SVC服务的其他项目,并且没有人遇到过这个问题(据我所知)。
UPDATE 2: Below is the config file. I have typed in the config file but have tried to keep this as accurate as possible. (please ignore case-sensitive things)
更新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>
1 个解决方案
#1
1
I won't say this as complete answer, but this somewhat helped solve our problem. I still want to know reason / solution to actual cause of the problem. I am mentioning this work around as this might help somebody Temporarily resolve their issues as well who might face similar problem.
我不会说这是完整的答案,但这有助于解决我们的问题。我仍然想知道问题的实际原因的原因/解决方案。我提到这项工作,因为这可能有助于某人暂时解决他们的问题以及可能面临类似问题的人。
As I mentioned the issue was coming only when application was idle for some time. In that case IIS was shutting down (unloading) the application's AppDomain (This is from SVC Logs).
正如我所提到的那样,只有在应用程序闲置一段时间后才会出现问题。在这种情况下,IIS正在关闭(卸载)应用程序的AppDomain(这是来自SVC Logs)。
So we created a simple console app that was hitting all the services of our application every 5-10 minutes and was not letting AppDomain to shut down. There is an alternative way for achiving this - Setting IIS configuration to not to unload AppDomain (this was less feisible for us provided the shared infrastructure). This helped us to complete testing.
因此,我们创建了一个简单的控制台应用程序,每隔5-10分钟就会访问我们应用程序的所有服务,并且不会让AppDomain关闭。有一种替代方法可以实现这一点 - 将IIS配置设置为不卸载AppDomain(对于我们来说,这对共享基础架构来说不太可行)。这有助于我们完成测试。
Then as we moved to load-balanced environments (Testing environments close to production), we suddenly stopped getting the issue and with some analysis we found that the Load-Balancer itself was pinging these services so as to make sure that they are up, and because of this App Domain of these services was never unloading.
然后,当我们转向负载均衡的环境(测试环境接近生产)时,我们突然停止了解问题,通过一些分析,我们发现Load-Balancer本身正在ping这些服务,以确保它们已启动,并且因为这些服务的App域从未卸载过。
So, for now we can say that we are not getting this issue in a load balanced environment, but the question still remains why was it even happening (for non load Balanced environments).
所以,现在我们可以说我们没有在负载平衡的环境中得到这个问题,但问题仍然存在,为什么它甚至发生(对于非负载平衡环境)。
#1
1
I won't say this as complete answer, but this somewhat helped solve our problem. I still want to know reason / solution to actual cause of the problem. I am mentioning this work around as this might help somebody Temporarily resolve their issues as well who might face similar problem.
我不会说这是完整的答案,但这有助于解决我们的问题。我仍然想知道问题的实际原因的原因/解决方案。我提到这项工作,因为这可能有助于某人暂时解决他们的问题以及可能面临类似问题的人。
As I mentioned the issue was coming only when application was idle for some time. In that case IIS was shutting down (unloading) the application's AppDomain (This is from SVC Logs).
正如我所提到的那样,只有在应用程序闲置一段时间后才会出现问题。在这种情况下,IIS正在关闭(卸载)应用程序的AppDomain(这是来自SVC Logs)。
So we created a simple console app that was hitting all the services of our application every 5-10 minutes and was not letting AppDomain to shut down. There is an alternative way for achiving this - Setting IIS configuration to not to unload AppDomain (this was less feisible for us provided the shared infrastructure). This helped us to complete testing.
因此,我们创建了一个简单的控制台应用程序,每隔5-10分钟就会访问我们应用程序的所有服务,并且不会让AppDomain关闭。有一种替代方法可以实现这一点 - 将IIS配置设置为不卸载AppDomain(对于我们来说,这对共享基础架构来说不太可行)。这有助于我们完成测试。
Then as we moved to load-balanced environments (Testing environments close to production), we suddenly stopped getting the issue and with some analysis we found that the Load-Balancer itself was pinging these services so as to make sure that they are up, and because of this App Domain of these services was never unloading.
然后,当我们转向负载均衡的环境(测试环境接近生产)时,我们突然停止了解问题,通过一些分析,我们发现Load-Balancer本身正在ping这些服务,以确保它们已启动,并且因为这些服务的App域从未卸载过。
So, for now we can say that we are not getting this issue in a load balanced environment, but the question still remains why was it even happening (for non load Balanced environments).
所以,现在我们可以说我们没有在负载平衡的环境中得到这个问题,但问题仍然存在,为什么它甚至发生(对于非负载平衡环境)。