简体   繁体   中英

C# Service HTTP Request ignoring custom timeout values

I have two applications working together. The first is the client that communicates with the second, the service. Both are written in C#/.NET.

The client has a web page which submits a form based on previously submitted data (also within the client).

The submission in question is handled by the service.

For the most part, the submissions are fine but in somewhat rare scenarios there can be many (200+) elements to handle on the submission. This is where the timeout issue comes in.

Setting up a try/catch block where the submission is handled results in the following:

catching error: System.ServiceModel.FaultException 1[System.ServiceModel.ExceptionDetail]: The HTTP request to 'WSDL SERVICE HERE' has exceeded the allotted timeout of 00:01:00. The time allotted to this operation may have been a portion of a longer timeout. (Fault Detail is equal to An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:

So I've toyed with the Web.config files in both the client and the service, setting binding tags with the following:

openTimeout="00:10:00" closeTimeout="00:10:00" sendTimeout="00:10:00" receiveTimeout="00:10:00"

What's odd is that if I set it to anything greater than 1 minute (notably in the client), the custom values are not recognized. If I set the values to less than 1 minute, the custom values are recognized.

I've also played around with maxReceivedMessageSize , maxBufferSize and maxBufferPoolSize but to no avail.

I really do not think it is something related to the logic in either application as if the element count is ~<100 there is not an issue. But we do have to be able to handle element counts of 200+.

Setting breakpoints in both applications has helped a bit but really hasn't gotten me anywhere.

Any insight on this is appreciated.

Use the below settings for both server and client. In our service we use this to traffic huge volume of data seems to work for us.

 <system.serviceModel> <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> <bindings> <basicHttpBinding> <binding name="basicHttp" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Mtom" transferMode="Streamed"> <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/> </binding> </basicHttpBinding> </bindings> <services> <service behaviorConfiguration="ServiceBehavior" name="MyService"> <endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicHttp" name="MyService" bindingNamespace="CustomNameSpace" contract="IService"> <identity> <dns value="localhost" /> </identity> </endpoint> </service> </services> <behaviors> <endpointBehaviors> <behavior name="web"> <webHttp /> </behavior> </endpointBehaviors> <serviceBehaviors> <behavior name="ServiceBehavior"> <serviceMetadata httpGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="true" /> </behavior> </serviceBehaviors> </behaviors> </system.serviceModel> 

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