views:

156

answers:

2

Hi,

I have a web service which is returning data to the desktop application. The problem I am having is, when the web service returns small volume of data everything works fine but when the volume of data is large it throws the following exception:

System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a receive.

And when I am debugging the web service, I see that this particular method is called twice. It executes the return statement 1st time nothing happens, but when it does execute it for the second time the above mentioned exception is thrown in the desktop app.

I found similar posts before on stackoverflow but they did not solve my problem. Can anybody please tell me what's going on in here?

Thanks!

+1  A: 

It could be because the size of the message is greater than the default message size. You might try increasing the this value in the configuration of the endpoint. You could also take a look at this post.


UPDATE:

To further diagnose the problem I would suggest you activating the trace on the service by putting the following in the config file:

<system.diagnostics>
    <trace autoflush="true">
    </trace>
    <sources>
        <source name="System.ServiceModel"
                switchValue="Information, ActivityTracing"
                propagateActivity="true">
            <listeners>
                <add name="sdt"
                     type="System.Diagnostics.XmlWriterTraceListener"
                     initializeData="WcfDetailTrace.e2e" />
            </listeners>
        </source>
    </sources>
</system.diagnostics>

This will generate the WcfDetailTrace.e2e trace file which you could open with the Service Trace Viewer Tool which will provide you with extensive information about the call and the error message.

Darin Dimitrov
The size is not the problem. I am setting the size to 16 MB and the data being transferred is less than that.I already did look at both the mentioned posts, but did not seem to help. Any other suggestions please?Thanks..
Saurabh Lalwani
@Saurabh, please see my update.
Darin Dimitrov
A: 

Did you find a solution to this?