I’m making a call to a WCF service but I get a CommunicationException on the client while receiving the response from the service.
System.ServiceModel.CommunicationException: An error occurred while receiving the HTTP response to http://localhost:8080/Service. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details. —> System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a receive. —> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. —> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
- The client that makes the call is a WCF proxy client.
- The service method executes without
any exceptions. - The WCF call works fine in those cases where it does not
take a long time for the serivce
method to finish. - The WCF call fails with the above exception message when the service method is taking long time to finish.
The sendTimeout property of the client’s binding has been increased to 30 minutes to accommodate the time it can take for the service method to finish.
Try to set the
receiveTimeoutequal or greater than the time it takes for the service method to complete. The default value for thereceiveTimeoutproperty is 10 minutes. So if the service method takes longer time to complete the connection will be closed (if no other activity takes place before thereceiveTimeoutoccurs). ThereceiveTimeoutproperty is described here.