views:

1002

answers:

3

I am calling a WCF Web Service locally (or remotely) that is working fine with small amounts of data (about 25 lines of < 1K of data ea). But when the data gets larger (about 300 lines) the web service fails. Below is the Exception, Inner Exception, and Stack Trace from the Inner Exception.

The service also seems to be taking unusually long to execute locally (I add this because it may give you some hint in solving). Getting the large amount of data takes 3s server-side and the small about of data takes 1s server-side. However, running the web service (locally) to get the small amount of data back takes 24s.

I have also included the binding information from the app.config from my client test application.

=========BINDING INFORMATION===========

<system.serviceModel>
  <bindings>
    <basicHttpBinding>
      <binding name="BasicHttpBinding_IFormsService" closeTimeout="00:01:00"
          openTimeout="00:01:00" receiveTimeout="02:00:00" sendTimeout="00:02:00"
          allowCookies="false" bypassProxyOnLocal="false" 
          hostNameComparisonMode="StrongWildcard"
          maxBufferSize="2147483647" maxBufferPoolSize="2147483647" 
          maxReceivedMessageSize="2147483647"
          messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
          useDefaultWebProxy="true">
        <readerQuotas maxDepth="32" maxStringContentLength="1000000000" 
                      maxArrayLength="1000000000"
                      maxBytesPerRead="4096" maxNameTableCharCount="16384" />
        <security mode="None">
           <transport clientCredentialType="None" 
                      proxyCredentialType="None" realm="" />
           <message clientCredentialType="UserName" algorithmSuite="Default" />
        </security>
     </binding>
  </basicHttpBinding>
</bindings>
<client>
  <endpoint 
        address="http://monica-pc/TrialIQSvc/FormsService.svc/FormsService/FormsService.Svc"
        binding="basicHttpBinding" 
        bindingConfiguration="BasicHttpBinding_IFormsService"
        contract="WebService.IFormsService" name="BasicHttpBinding_IFormsService" />
</client>

=========EXCEPTION DATA=============

Exception: An error occurred while receiving the HTTP response to http://monica-pc/TrialIQSvc/FormsService.svc/FormsService/FormsService.Svc. 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.

Inner Exception: The underlying connection was closed: An unexpected error occurred on a receive. Stack trace: Server stack trace: at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason) at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout) at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs) at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at Test.WebService.IFormsService.GetFormGroupInstance(String formGroupId, String subjectId, String userId) at Test.WebService.FormsServiceClient.GetFormGroupInstance(String formGroupId, String subjectId, String userId) in G:\SVNTrialIQ\trunk\Common\trunk\source\Forms\Test\Service References\WebService\Reference.cs:line 59 at Test.Form1.btnInstanceInfo_Click(Object sender, EventArgs e) in G:\SVNTrialIQ\trunk\Common\trunk\source\Forms\Test\Form1.cs:line 408

A: 

To get extended error information try using SvcTraceViewer.

Darin Dimitrov
Yup! That did it. I could not get a trace log to appear on my dev machine (Vista). But, when I look at the IIS 7 interface provided with Vista, I have to admit it makes me feel like I never touched a computer before in my life. So I didn't do too much troubleshooting.
monica
However, running the trace code in the web.config on my Win2003 server revealed it was a Type error due to inheritance, which is rather unrelated, but is described nicely here: http://developers.de/blogs/damir_dobric/archive/2009/03/24/about-quot-knowntypeattribute-quot-example.aspx
monica
A: 

Could be that you are missing some configuration on the server side

Shiraz Bhaiji
+1  A: 

There's a number of things that could go wrong.

First of all, as "darin" already suggested - try turning on the message tracing and see what that produces.

Second - you could be running into a timeout. You said your small data set took about 24 seconds to return, your larger data set is 12 times as big (300 vs. 25 lines), so that could take 288 seconds - but your sendTimeout is set to 2 minutes - so that might be the reason. Try increasing that setting to let's say 10 minutes - that should be ample time:

<binding name="BasicHttpBinding_IFormsService" 
          sendTimeout="00:10:00"

If that doesn't solve it - you could try to use streaming in order to move back the large amounts of data:

<binding name="BasicHttpBinding_IFormsService" 
         transferMode="StreamedResponse">

As long as it's only your responses that are big, that should work. Of course, you'd have to rearchitect your client calling the service a bit to handle streaming (create an operation contract = service method that returns a Stream as its return value, and use the stream to read the data in chunks from the server). If that's a common scenario for you, that might work and be well worth the effort (and it would allow you to reduce your buffer sizes again, to avoid a denial-of-service attack by being flooded with huge messages).

See a great intro to WCF message streaming for more information on streaming.

And if nothing helps - come back and let us know!

Marc

marc_s
I look at the streaming article. Great reference! Performance tuning is my next step.
monica