I'm getting the following exception The operation has timed out
when calling my WCF REST service.
I basically have a WCF Web Service project and a web site which references the compiled WCF assembly. The web service works a charm, so my problem is not down to having an incorrect binding, endpoint or service definition in my web.config.
The problem only occurs if I try to insert a large amount of data.
The web.config contains the following info:
<system.web>
<compilation debug="true" targetFramework="4.0"/>
<httpRuntime enable="true" executionTimeout="100000"
maxRequestLength="2147483647"/>
</system.web>
<bindings>
<webHttpBinding>
<binding maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647"
receiveTimeout="00:10:00"
sendTimeout="00:10:00">
<readerQuotas maxStringContentLength="2147483647"/>
</binding>
</webHttpBinding>
</bindings>
My WCF web service is not referenced in the the project (windows service) as I'm using a wrapper (sdk) which takes care of making all the relevant http request and convert object to json and vice versa. All http request are made via the WebClient which is called the sdk. In this instance:
byte[] returnBuffer = await client.UploadDataTaskAsync(uriString,
"POST", requestBuffer);
While this is happening on a live site (Yikes!!), I can easily reproduce the problem by putting a breakpoint in my web service and letting it hang for 90 seconds or so, then if I try to continue stepping through, the specific error is generated and while it's attempting to continue to run the remaining of the code within the function, the exception is returned back to the client.
I've been googling this problem for hours now but I'm not getting anywhere with this. My web service still times out the default 90 seconds.
Another thing I'm wondering about. I've been reading a lot of various article saying mentioning that the client app, in my case my windows service should have binding, endpoint, etc... information in the app.config. I have none, nor have I ever needed one up to now. Should I look into this?? It really does appear that the timeout is happening on the web service rather than the client end.
Any ideas?
Thanks.
UPDATE:
I've added additional info about my web.config (i.e. service & behaviour definitions):
<services>
<service name="MyCompany.Web.Services.WebDataService"
behaviorConfiguration="WebDataServiceBehaviour">
<endpoint address="" binding="webHttpBinding"
contract="MyCompany.Web.Services.IWebDataService"
behaviorConfiguration="webBehaviour">
</endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WebDataServiceBehaviour">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="webBehaviour">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
I'm going to answer my own question as I wanted to clarify a few things:
This has nothing to do with having invalid settings in the web.config as the problem was client-side related. It is easy to assume that the problem is server side related but this was not the case in this instance.
There is no point setting the ServiceModel (address, binding, contract) configuration in the app.config on the client-side as I'm calling the WebClient object which as far I'm aware is totally unaware of type of service I'm calling and these settings are quite specific to WCF and while my service is a WCF REST web service and does require a ServiceModel settings on the server end, the WebClient object is totally unaware of these.
The answer to my problem was found in the article How can I change the time limit for webClient.UploadData()?. After making the relevant changes, I test this thoroughly and it's also been deployed on the live site that were having the timeout problem and the problem has definitely been resolved when uploading a large amount of data.
Thanks.