tags:

views:

241

answers:

2

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.

+1  A: 

Try to set the receiveTimeout equal or greater than the time it takes for the service method to complete. The default value for the receiveTimeout property 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 the receiveTimeoutoccurs). The receiveTimeout property is described here.

TruckerG
I've changed those timeout properties and still have the same problem. I used [OperationContract(IsOneWay = true)] in the contract. Do you believe timeout is an issue? My other service operation works nice, but just this one doesn't work. Do you have any clue about that?
Eduardo Xavier
+1  A: 

A very long operation like this should most likely be called asynchronously - in other words, the client asks the server to prepare the data, then gets on with something else while the server does the work. When the server's finished it calls the client back.

Asynchronous WCF operations are discussed here.

Jeremy McGee