我在配置如下的Windows服务中托管了一个自定义WCF服务:
<system.web>
<httpRuntime maxRequestLength="512000000" />
<compilation debug="true" />
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<client />
<bindings>
<customBinding>
<binding name="ESSMexBinding">
<tcpTransport maxPendingConnections="20" listenBacklog="20">
<connectionPoolSettings groupName="default" maxOutboundConnectionsPerEndpoint="20" />
</tcpTransport>
</binding>
</customBinding>
<netTcpBinding>
<binding name="ESSTcpBinding" sendTimeout="00:15:00" closeTimeout="0:10:00" receiveTimeout="0:15:00" openTimeout="00:15:00"
transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" listenBacklog="20"
maxBufferPoolSize="512000000" maxBufferSize="512000000"
maxConnections="20" maxReceivedMessageSize="512000000">
<readerQuotas maxDepth="32" maxStringContentLength="512000000" maxArrayLength="512000000" maxBytesPerRead="512000000" maxNameTableCharCount="512000000" />
<security mode="Transport">
<transport clientCredentialType="Windows" />
</security>
<!--<security mode="None" />-->
<!--<reliableSession
ordered="true"
inactivityTimeout="00:15:00"
enabled="true" />-->
</binding>
</netTcpBinding>
</bindings>
<services>
<service name="ESService.ESS" behaviorConfiguration="ESServiceBehavior">
<clear />
<endpoint address="" binding="netTcpBinding" bindingConfiguration="ESSTcpBinding" name="ESTCPEndpoint"
contract="ESService.IESService" listenUriMode="Explicit">
<identity>
<dns value="localhost" />
<certificateReference storeName="My" storeLocation="LocalMachine" x509FindType="FindBySubjectDistinguishedName" />
</identity>
</endpoint>
<endpoint address="mex" binding="customBinding" bindingConfiguration="ESSMexBinding" name="ESMEXEndpoint" contract="IMetadataExchange" listenUriMode="Explicit">
<identity>
<dns value="localhost" />
<certificateReference storeName="My" storeLocation="LocalMachine" x509FindType="FindBySubjectDistinguishedName" />
</identity>
</endpoint>
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8888/ESService" />
</baseAddresses>
<timeouts closeTimeout="00:02:00" openTimeout="00:02:00" />
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ESServiceBehavior">
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="false" />
<bufferedReceive maxPendingMessagesPerChannel="255" />
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceTimeouts transactionTimeout="00:15:00" />
<serviceThrottling maxConcurrentCalls="200" maxConcurrentSessions="100" maxConcurrentInstances="100" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
有时服务变得无响应,甚至无法从.Close
调用OnStop()
方法-Windows服务挂起为Stopping状态。
我研究了svclog
文件,但有两个问题:
第一个非致命问题::看起来每个WCF请求都以以下两种异常之一结束,它们在服务器处理请求“服务已处置”后60秒被记录下来:
由于线程退出或线程中断,I / O操作被中止。 申请请求
或
远程主机强行关闭了现有连接
但是,即使在svclog中记录了那些异常,该服务也能正常工作。
是否与
<timeouts closeTimeout="00:02:00" openTimeout="00:02:00" />
第二个致命问题
有时在2分钟的时间间隔内,日志文件中会出现一系列非常多的请求,此后,WCF服务变得无响应,并且Windows服务在停止时挂起,处于“停止”状态,无法完成执行WCF的服务Close方法。必须重新启动服务器才能使其重新工作。
记录的异常如下:
我已经观察到奇怪请求的时间与事件日志中的APM代理错误4009和4151完全冲突。当我们尝试删除SCOM APM代理时,APM错误消失了,但问题仍然存在。
那意味着什么?星期六早上5:14至少发生了两次,当时没有客户端连接。可能是一些监控软件吗?我怎么知道哪个IP地址发出了请求?我有一个问题,我对该服务器没有本地管理员权限。