WCF distributed development common error (20): timeoutexception was unhandled

Source: Internet
Author: User
When developing a WCF application, if a large number of clients send requests to the WCF Service, this exception often occurs and times out. The WCF Service response times out. The operation is not enabled at the specified time 00:01:00. the time allocated to this operation may be only part of the timeout time. The error message is as follows:
The open operation did not complete within the allotted timeout of 00:01:00. The time allotted to this operation may have been a portion of a longer timeout.
[1] error:

[2] Cause Analysis:
The cause of this timeout exception is that a large number of client requests are sent to the service. The 100 clients I use here instantiate 100 proxies. Request. Simulate a large number of concurrent requests on the client. The service latency is 100 ms. Simulate processing. Here, when there are about 10 requests, service processing is blocked. Then wait, and a timeout exception occurs.
[3] solution:
When a large number of requests are involved, you can consider using the servicethrottlingbehavior attribute of WCF. Description
Maxconcurrentcils gets or sets a value that specifies the maximum number of messages processed in the entire servicehost.
Maxconcurrentinstances gets or sets a value that specifies the maximum number of instancecontext objects that can be executed at a time in the service.
Maxconcurrentsessions gets or sets the maximum number of sessions that a specified servicehost object can accept at a time.

Here we can set the throttling behavior of the service. The details are as follows:

Code
<Servicebehaviors>
<Behavior name = "wcfservice. wcfservicebehavior">
<Servicetimeouts transactiontimeout = "00:01:00"/>
<Servicemetadata httpgetenabled = "true"/>
<Servicedebug includeexceptiondetailinfaults = "false"/>
<Servicethrottling maxconcurrentcils = "1000" maxconcurrentinstances = "1000" maxconcurrentsessions = "1000"/> -->
</Behavior>
</Servicebehaviors


Here, 1000 can be modified based on your actual requirements for the WCF Service. Service Activation type and instance call method. Then adjust. After the modification, restart the service.
Reference: http://msdn.microsoft.com/en-us/library/system.servicemodel.description.servicethrottlingbehavior_properties.aspx

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.