我的服务器响应有问题。当一个操作在服务器端花费超过一分钟时,客户端无法获得响应,但是日志说,而不是从服务器发送响应。当服务器端的操作不到一分钟时,一切都很好。
客户端配置:
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="NewBehavior0">
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
<clientCredentials />
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_B2BServices" closeTimeout="00:10:00"
openTimeout="00:01:00" receiveTimeout="00:21:00" sendTimeout="00:21:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Mtom" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<reliableSession ordered="true" inactivityTimeout="00:15:00"
enabled="true" />
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address=https://.../MatrixConnector/Services.svc
behaviorConfiguration="NewBehavior0"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_B2BServices"
contract="MatrixServiceReference.B2BServices" name="WSHttpBinding_B2BServices">
<identity>
<dns value="..." />
</identity>
</endpoint>
</client>
</system.serviceModel>
服务器端:
<system.serviceModel>
<diagnostics>
<messageLogging logEntireMessage="true" logKnownPii="true" logMalformedMessages="true"
logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true"
maxMessagesToLog="2147483647" maxSizeOfMessageToLog="2147483647" />
<endToEndTracing propagateActivity="true" activityTracing="true"
messageFlowTracing="true" />
</diagnostics>
<bindings>
<wsHttpBinding>
<binding name="WsHttpBinding"
closeTimeout="00:21:00" openTimeout="00:02:00" receiveTimeout="00:30:00" sendTimeout="00:30:00"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Mtom">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<reliableSession enabled="true" inactivityTimeout="00:20:00" />
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="None" />
<message clientCredentialType="UserName" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="serviceBehavior" name="mediaSens.Services.B2BServices">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="WsHttpBinding"
contract="mediaSens.Services.IB2BServices">
<identity>
<dns value="..." />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress=http://.../ />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="serviceBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom"
customUserNamePasswordValidatorType="mediaSens.Services.CustomUserNameValidator, mediaSens.Services" />
</serviceCredentials>
<serviceThrottling maxConcurrentCalls="1000" maxConcurrentSessions="2000"
maxConcurrentInstances="1500" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" minFreeMemoryPercentageToActivateService="1" />
</system.serviceModel>
现在我在30分钟后在服务器端出现错误:
The communication object, System.ServiceModel.Channels.ReplyChannel, cannot be used for communication because it has been Aborted.
所有属性都设置在20分钟以上,客户端无法处理超过一分钟的操作。 另外我做了:
client.InnerChannel.OperationTimeout = new TimeSpan(0, 30, 0);
......但没有结果。
我增加了应用程序池设置: Ping最大响应时间:1140秒 关机时间限制:1200秒 平期:30秒。
我也把recycilng关了。相同的行为。
我尝试关闭relabionSession但没有......
修改 我发现,客户在90秒后无法得到答案。这是IIS中exececutionTime的默认值。我已将此值增加到3600秒,关闭调试但客户端在此之后仍无法检索任何响应。 我已经创建了net.tcp服务器和相同的结果,但在localhost中没有这样的问题。我真的很困惑......
答案 0 :(得分:1)
<system.web>
<hostingEnvironment idleTimeout="600" shutdownTimeout="700" />
</system.web>
此代码解决了这个问题。
答案 1 :(得分:0)
在客户端配置文件中增加打开超时