简体   繁体   中英

Time Out in WCF service

I am consuming a WCF service within a console application. I have a server method which returns a list of companies depending on the sector passed as a parameter.

The flowing code fails and throws a time Out exception after 5 minutes.

List<Company> companies = EService.GetCompanies(1755);

While in the app.config I have already set the time Out:

sendTimeout="23:20:00" receiveTimeout="23:20:00" maxReceivedMessageSize = "1000000000"                        
closeTimeout="23:20:00"

Thanks

Hey In your binding configuration, there are four timeout values

<bindings>
 <basicHttpBinding>
  <binding name="InTimeout"
         sendTimeout="00:20:00">
  </binding>
</basicHttpBinding>

The most important is the sendTimeout , which says how long the client will wait for a response from your WCF service. You can specify hours:minutes:seconds in your settings - in my sample, I set the timeout to 25 minutes.

The openTimeout as the name implies is the amount of time you're willing to wait when you open the connection to your WCF service. Similarly, the closeTimeout is the amount of time when you close the connection (dispose the client proxy) that you'll wait before an exception is thrown.

The receiveTimeout is a bit like a mirror for the sendTimeout - while the send timeout is the amount of time you'll wait for a response from the server, the receiveTimeout is the amount of time you'll give you client to receive and process the response from the server.

In case you're send back and forth "normal" messages, both can be pretty short - especially the receiveTimeout , since receiving a SOAP message, decrypting, checking and deserializing it should take almost no time. The story is different with streaming - in that case, you might need more time on the client to actually complete the "download" of the stream you get back from the server.

There's also openTimeout, receiveTimeout, and closeTimeout.

You can also refer that link WCF Timeout

Hope it helps you

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM