Wcf 如何增加绑定上的SendTimout值?

Wcf 如何增加绑定上的SendTimout值?,wcf,Wcf,当我在客户机上执行命令时,它会等待响应。我知道这个命令需要很长时间,但默认超时时间似乎是1分钟左右。每次从客户端调用命令时,都会出现以下错误: 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 p

当我在客户机上执行命令时,它会等待响应。我知道这个命令需要很长时间,但默认超时时间似乎是1分钟左右。每次从客户端调用命令时,都会出现以下错误:

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>


我不确定在哪里改变时间。谢谢。

social.msdn.microsoft.com/Forums/en-US/wcf/thread/84551e45-19a2-4d0d-bcc0-516a4041943d/



检查您的接收超时

TimeSpan值,指定为接收操作完成提供的时间间隔。此值应大于或等于零。默认值为00:10:00

<wsHttpBinding>

 <binding name="httpBinding"

 closeTimeout="00:05:00"