2013-02-07 70 views
0

當我在客戶端上執行命令時,它等待響應。我知道這個命令需要很長時間,但默認的超時時間似乎大約是1分鐘。每當我從客戶端調用命令時,我都會收到此錯誤:如何增加綁定上的SendTimout值?

System.TimeoutException was unhandled 
    HResult=-2146233083 
    Message=The request channel timed out while waiting for a reply after 00:00:59.9809981. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout. 
    Source=mscorlib 
    StackTrace: 
    Server stack trace: 
     at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout) 
     at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout) 
     at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) 
     at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) 
     at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message) 
    Exception rethrown at [0]: 
     at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) 
     at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) 
     at Client.CommandServices.CommandService.Execute(Object command) 
     at Client.CommandServices.CommandServiceClient.Execute(Object command) in c:\TFS\Solid\Client\Service References\CommandServices\Reference.cs:line 58 
     at Client.Code.WcfServiceCommandHandlerProxy`1.Handle(TCommand command) in c:\TFS\Solid\Client\Code\WcfServiceCommandHandlerProxy.cs:line 13 
     at Client.Controllers.CommandExampleController.ExecuteGenericCommand() in c:\TFS\Solid\Client\Controllers\CommandExampleController.cs:line 62 
     at Client.Program.Main(String[] args) in c:\TFS\Solid\Client\Program.cs:line 25 
    InnerException: System.TimeoutException 
     HResult=-2146233083 
     Message=The HTTP request to 'http://localhost:9999/CommandService.svc' has exceeded the allotted timeout of 00:00:59.9870000. The time allotted to this operation may have been a portion of a longer timeout. 
     Source=System.ServiceModel 
     StackTrace: 
      at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason) 
      at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) 
      at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout) 
     InnerException: System.Net.WebException 
      HResult=-2146233079 
      Message=The operation has timed out 
      Source=System 
      StackTrace: 
       at System.Net.HttpWebRequest.GetResponse() 
       at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) 
      InnerException: 


"The HTTP request to 'http://localhost:9999/CommandService.svc' has exceeded the allotted timeout of 00:00:59.9870000. The time allotted to this operation may have been a portion of a longer timeout."} 

The HTTP request to 'http://localhost:9999/CommandService.svc' has exceeded the allotted timeout of 00:00:59.9870000. The time allotted to this operation may have been a portion of a longer timeout. 

這是客戶端中的app.config。

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <startup> 
     <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> 
    </startup> 
    <system.serviceModel> 
     <bindings> 
      <basicHttpBinding> 
       <binding name="BasicHttpBinding_CommandService" /> 
       <binding name="BasicHttpBinding_QueryService" /> 
      </basicHttpBinding> 
     </bindings> 
     <client> 
      <endpoint address="http://localhost:9999/CommandService.svc" 
       binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_CommandService" 
       contract="CommandServices.CommandService" name="BasicHttpBinding_CommandService" /> 
      <endpoint address="http://localhost:9999/QueryService.svc" binding="basicHttpBinding" 
       bindingConfiguration="BasicHttpBinding_QueryService" contract="QueryServices.QueryService" 
       name="BasicHttpBinding_QueryService"/> 
     </client> 
    </system.serviceModel> 
</configuration> 

...這裏是WCF服務的web.config。

<?xml version="1.0"?> 
<configuration> 

    <appSettings> 
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" /> 
    </appSettings> 
    <system.web> 
    <compilation debug="true" targetFramework="4.5" /> 
    <httpRuntime targetFramework="4.5"/> 
    </system.web> 
    <system.serviceModel> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior> 
      <!-- To avoid disclosing metadata information, set the values below to false before deployment --> 
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="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> 
    <protocolMapping> 
     <add binding="basicHttpsBinding" scheme="https" /> 
    </protocolMapping>  
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> 
    </system.serviceModel> 
    <system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"/> 
    <!-- 
     To browse web app root directory during debugging, set the value below to true. 
     Set to false before deployment to avoid disclosing web app folder information. 
     --> 
    <directoryBrowse enabled="true"/> 
    </system.webServer> 
    <connectionStrings> 
    <add name="MainframeEntities" connectionString="metadata=res://*/MainframeEntities.csdl|res://*/MainframeEntities.ssdl|res://*/MainframeEntities.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=IT-DEV;initial catalog=Mainframe;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" /> 
    </connectionStrings> 

</configuration> 

我不確定在哪裏更改計時。謝謝。

回答

0

經過您的receiveTimeout

一TimeSpan值,用於指定爲完成接收操作而提供的時間間隔。該值應該大於或等於零。默認值是00:10:00。