Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

System.Net.WebException: The request was aborted: the request was cancelled

I have a WCF service that has been giving me this error under load conditions (and I can't seem to recreate the error otherwise). We've been trying to find a way around it for about a week now with no such luck..

The error I see has two parts to it,

System.ServiceModel.CommunicationException: An error: (The request was aborted: the request was cancelled.) occurred while transmitting data over the http channel.

and:

System.Net.WebException: The request was aborted: the request was cancelled.

I've seen many people suggest to disable working with keep alive by overloading a method in the Reference.cs file and setting KeepAlive = false, however, our client side is using a service reference (in addition to web reference) and this option does not exist anymore.

Another option I've seen was to add a custom Binding to the service instead of the BasicHttpBinding we are using now, but that would bother backwards support of the webservice to those who have been using a webReference (since CustomBinding is not SOAP enabled).

Has anyone dealt with this error before? Is there a way to disable keep alive in WCF without affecting the server side? Is there anything other that keep alive that is known to cause this error?

like image 547
Audzzy Avatar asked Oct 10 '10 11:10

Audzzy


2 Answers

I don't think that HTTP keep alive is responsible for this. WCF should be able to handle this by itself so the HTTP persistant connection is shared among requests and if it expires (it expires after 100s of inactivity) WCF creates new one without firing any exception. If your connection is aborted during request transmission then I expect there will be some other problem.

You can use this custom binding as equivalent to BasicHttpBinding without HTTP keep alive:

<bindings>
  <customBinding>
    <binding name="NoKeepAlive">
      <textMessageEncoding messageVersion="Soap11" />
      <httpTransport keepAliveEnabled="false" />
    </binding>
  </customBinding>
</bindings> 
like image 80
Ladislav Mrnka Avatar answered Oct 05 '22 04:10

Ladislav Mrnka


I had this problem when trying to upload large files. I had to add this to the web.config of the web services

<system.web>
  <httpRuntime maxRequestLength="10240" />
like image 30
nuander Avatar answered Oct 05 '22 03:10

nuander