views:

97

answers:

2

Hi folks,

I have a WCF service, that is called from my Silverlight 3 application (with C#). The service is called for each item in a user filled listbox. When only one item is contained in the listbox, everything works fine. Multiple items cause an error sometimes. I tested a bit around and sometimes I get an error with 2 items, sometimes not. With 4 items test, one time I get 2 results returned, after that the error.

Worst thing, that the error simply says "The Remoteserver has returned an Error: NotFound". The Error is a "CommunicationException" and is thrown in the EndMethod(System.IAsyncResult result) method

Here's the call:

foreach (ListBoxItem lbItem in categorySeeds)
{
 Helper.Instance.service.ClusterAsync(Helper.Instance.language.value,
  ((KeyValuePair<string, int>)lbItem.Tag).Value,
  Helper.Instance.clusterLevel,
  Helper.Instance.clusterDelay,
     Helper.Instance.clusterTolerance,
  Helper.Instance.clusterMaxCategories,
  Helper.Instance.similarity);
}

I remember that I once "solved" the problem by calling "reuse" of the AppPool that contained my WCF ... so maybe there is something wrong with the configuration? Does anyone know if I can make the WCF returning a more meaningful error message than just "NotFound"?

Thanks in advance, Frank

ANSWER: The problem was caused by the concurrent access of the multiple WCF-Service-Calls. The service calls StoredProcedures that work with a Synonym-Objects that each SP changes to a value given by a parameter ... so I have to fix it there.

+1  A: 

The WCF server will have a maximum number of concurrent calls and concurrent sessions, which are 10 and 16 respectively. If you call that service too quickly with more than that number of calls, you could get timeouts and/or messages being rejected.

This is a service behavior (serviceThrottling) which is indeed configurable on the server:

<serviceBehaviors>
   <behavior name="YourServiceBehavior">
       <serviceDebug includeExceptionDetailInFaults="True" />
       <serviceThrottling 
          maxConcurrentCalls="25"
          maxConcurrentInstances="25"
          maxConcurrentSessions="25"/>
   </behavior>
</serviceBehaviors>

The generic error message you get back from WCF is totally on purpose - the WCF designers didn't want to reveal anything to an outside caller that might help him to exploit your system. That, too, can be tweaked by a service behavior, which then returns a more meaningful error message to you:

<serviceBehaviors>
   <behavior name="YourServiceBehavior">
       <serviceDebug includeExceptionDetailInFaults="True" />
   </behavior>
</serviceBehaviors>
marc_s
The problem described must be quite common, surely the solution isn't to fiddle around with the throttling? The client won't just open up so many connections to the same server so easily, surely it would queue such requests on the client and only have a few concurrent requests outstanding. In addition the OP describes problems at times with just two entries so I can't se how the throttle change will help. I suspect the detailed exceptions will reveal serverside code not handling concurrency of multiple calls properly.
AnthonyWJones
You are absolutely right, Anthony. I already had the serviceDebug property in place, but when consuming an WCF with Silverlight 3, you have to struggle a bit more to really get the error: http://msdn.microsoft.com/en-us/library/dd470096(VS.96).aspx - After getting this in place, I found that the error is caused by the concurrent access at the SQL-StoredProcedures by the WCF-Service. I use a synonym to query different tables that have the same structure. But that's another story ... *sigh*
Aaginor
+2  A: 

You need to dispose the service after you call it. I had the same issue and i fixed it with using statement -

using (TempConvertService TMPConSvc =
new TempConvertService.TempConvertServiceClient())
{
result = TMPConSvc.ConvertToF(32.00);
return result;
}
bugBurger