Buffer Size in WCF Service

We have a WCF service that executes certain stored procedures and returns the results to the silverlight client. Some of the stored procedures return up to 80K lines.

Below are the settings in web.config for the service

<system.serviceModel> <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/> <behaviors> <serviceBehaviors> <behavior name="MyService.MyServiceBehavior"> <serviceMetadata httpGetEnabled="true"/> <serviceDebug includeExceptionDetailInFaults="true"/> <dataContractSerializer maxItemsInObjectGraph="2147483647"/> </behavior> </serviceBehaviors> </behaviors> <bindings> <basicHttpBinding> <binding name="BasicHttpBinding_MyService" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" receiveTimeout="00:40:00" openTimeout="00:40:00" closeTimeout="00:40:00" sendTimeout="00:40:00"> <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/> <security mode="None"/> </binding> </basicHttpBinding> <customBinding> <binding name="MyService.MyService.customBinding0"> <binaryMessageEncoding/> <httpTransport/> </binding> </customBinding> </bindings> <services> <service behaviorConfiguration="MyService.MyServiceBehavior" name="MyService.MyService"> <endpoint name="BasicHttpBinding_MyService" address="" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_MyService" contract="MyService.IMyService"/> </service> </services> </system.serviceModel> 

And this is for the client

 <system.serviceModel> <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/> <behaviors> <serviceBehaviors> <behavior name="MyService_Behavior"> <serviceDebug includeExceptionDetailInFaults="true"/> <serviceMetadata httpGetEnabled="true"/> </behavior> </serviceBehaviors> <endpointBehaviors> <behavior name="r1"> <dataContractSerializer maxItemsInObjectGraph="2147483647"/> </behavior> </endpointBehaviors> </behaviors> <bindings> <basicHttpBinding> <binding name="BasicHttpBinding_MyService" closeTimeout="00:03:00" openTimeout="00:03:00" receiveTimeout="00:10:00" sendTimeout="00:03:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"> <security mode="None"/> </binding> </basicHttpBinding> </bindings> <client> <endpoint name="BasicHttpBinding_MyService" address="http://localhost:8080/MyService/MyService.svc" behaviorConfiguration="r1" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_MyService" contract="MyService.IMyService" /> </client> </system.serviceModel> 

Whenever the number of records goes beyond 20K, the service throws an error like TimeOut or NotFound. Why do you think this is happening? How can i fix this?

+6
c # silverlight wcf
source share
3 answers

It sounds like excessive data overload. Pagination, as noted in the comments, is a practical solution. If there is a good reason to want 80k, you can try using a different mechanism to serialize the data. For example, protobuf data is usually much smaller than xml, so you can try using this on a wire. However, since this is Silverlight, I cannot (currently) exchange it automatically - you will need to return byte[] or Stream and explicitly handle serialization / deserialization on the server / client. This should reduce the bandwidth requirements with a fair hit (even if you can configure Silverlight to use MTOM - I have not tested it recently, but it was not supported in some earlier versions).

+3
source share

As your proc returns 80K, you should also add your client-side buffer size.

readerQuotas

 <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/> 

That should work. If necessary, increase the size of the buffer.

+2
source share

We have successfully used GZIP compression between the client and the WCF service to increase the number of rows that we could cancel. You should also work for your needs.

We used MS libraries to achieve it: http://msdn.microsoft.com/en-us/library/ms751458.aspx

+1
source share

All Articles