views:

524

answers:

2

Hi,

I've got a real lemon on my hands. I hope someone who has the same problem or know how to fix it could point me in the right direction.

The Setup

I'm trying to create a WCF data service that uses an ADO Entity Framework model to retrieve data from the DB. I've added the WCF service reference and all seems fine. I have two sets of data service calls. The first one retrieves a list of all "users" and returns (this list does not include any dependent data (eg. address, contact, etc.). The second call is when a "user" is selected, the application request to include a few more dependent information such as address, contact details, messages, etc. given a user id. This also seems to work fine.

The Lemon

After some user selection change, ie. calling for more dependent data from the data service, the application stops to respond.

Crash error:

The request channel timed out while waiting for a reply after 00:00:59.9989999. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.

I restart the debugging process but the application will not make any data service calls until after about a minute or so, VS 08 displays a message box with error:

Unable to process request from service. 'http://localhost:61768/ConsoleService.svc'. Catastrophic failure.

I've Googled the hell out of this error and related issues but found nothing of use.

Possible Solutions

I've found some leads as to the source of the problem. In the client's app.config:

  1. maxReceivedMessageSize > Set to a higher value, eg. 5242880.
  2. receiveTimeout > Set to a higher value, eg. 00:30:00

I've tried these but all in vain. I suspect there is an underlying problem that cannot be fixed by simply changing some numbers. Any leads would be much appreciated.

+5  A: 

Hey guys/girls,

I've solved it =P.

Cause

The WCF service works fine. It was the data service calls that was the culprit. Every time I made the call, I instantiated a new reference to the data service, but never closed/disposed the service reference. So after a couple of calls, the data service reaches its maximum connection and halts.

Solution

Make sure to close/dispose of any data service reference properly. Best practice would be to enclose in a using statement.

using(var dataService = new ServiceNS.ServiceClient() )
{
    // Use service here        
}
// The service will be disposed and connection freed.
Tri Q
+2  A: 

Glad to see you fixed your problem.

However, you need to be carefull about using the using statement. Have a look at this article:

http://msdn.microsoft.com/en-us/library/aa355056.aspx

Shiraz Bhaiji