Is is a message size issue ? RRS feed

  • Question

  • Dear all,

    I have a service which collect data from SQL server database. So far everything was working fine until the time I have noticed that my service return crash based on the amount of data in the return list.

    If my table return has for instance 50 records it works ok
    If i increase the records to 130 then it fails. Data are retrive properly inside the service, but when they are return back to the client application, the client receive an Service.CommunicationException as follow :

    The socket connection was aborted. This could be caused by an error processing your message or a receive
    timeout being exceeded by the remote host, or an underlying network resource issue.
    Local socket timeout was '00:00:59.9940000'.
    And the innert stack is :

    Server stack trace: 
       at System.ServiceModel.Channels.StreamConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
       at System.ServiceModel.Channels.SessionConnectionReader.Receive(TimeSpan timeout)
       at System.ServiceModel.Channels.SynchronizedMessageSource.Receive(TimeSpan timeout)
       at System.ServiceModel.Channels.FramingDuplexSessionChannel.Receive(TimeSpan timeout)
       at System.ServiceModel.Channels.FramingDuplexSessionChannel.TryReceive(TimeSpan timeout, Message& message)
       at System.ServiceModel.Dispatcher.DuplexChannelBinder.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.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 Maillefer.Nomos.Types.Interface.IRecipeAdmin.GetAvailableRecipe(String LineId)
       at Maillefer.Nomos.Types.WcfProxies.RecipeAdministration.WCFRecipeClientService.GetAvailableRecipe(String LineId)
       at Maillefer.Nomos.Plateform.UI.Common.Data.RecipeAdminService.GetavailableRecipe() in E:\Maillefer\Developement PSU 6\_UI Software architecture\Maillefer.Nomos.Plateform.UI.Common\Data\RecipeAdminService.cs:line 40
    Hrere is my binding config:
            <binding name="NetTcpBinding" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="83887360" maxBufferSize="10485760" maxConnections="10" maxReceivedMessageSize="10485760">
              <security mode="Transport">
                <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
                <message clientCredentialType="Windows" />

    Could it be link to a WCF binding parmeter that I need to increase ?

    If yes which one can it be ?

    Thnaks for help
    Your experience is build from the one of others
    Thursday, October 8, 2009 10:21 AM


  • I have increase this MaxItemsInObjectGraph value but it has to be set in both config file, client and service aotherwise it is not working

    Your experience is build from the one of others
    Thursday, October 8, 2009 2:12 PM

All replies

  • Hi,

    Can you please try logging the message and from there we can find the error. Also increase the <maxReceivedMessageSize> value in the client and server to a sufficiently large value.You can use the following config setting to enable message logging.

          <source name="System.ServiceModel" switchValue="Warning,ActivityTracing"
              <add type="System.Diagnostics.DefaultTraceListener" name="Default">
                <filter type="" />
              <add name="ServiceModelTraceListener">
                <filter type="" />
          <source name="System.ServiceModel.MessageLogging" switchValue="Information,ActivityTracing">
              <add type="System.Diagnostics.DefaultTraceListener" name="Default">
                <filter type="" />
              <add name="ServiceModelMessageLoggingListener">
                <filter type="" />
          <add initializeData="D:\web_messages.svclog"
            type="System.Diagnostics.XmlWriterTraceListener, System, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089"
            name="ServiceModelMessageLoggingListener" traceOutputOptions="Timestamp">
            <filter type="" />
          <add initializeData="D:\web_tracelog.svclog"
            type="System.Diagnostics.XmlWriterTraceListener, System, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089"
            name="ServiceModelTraceListener" traceOutputOptions="Timestamp">
            <filter type="" />
        <trace autoflush="true" />

    Include this within the  <system.serviceModel> tag in your config file


    For more configuration on this , you can refer to :

    WCF Message Loging:

    WCF Tracing:

    Use this tool to view the logs :
    Thursday, October 8, 2009 10:58 AM
  • I have send to a file the return data from my storeprocedure before it is serialize on the wire :
    With a file size of 2.5 MB it goes ok, but if the file is 4.5 MB it crash.

    I know it is not the final message size when serialize as WCF add some more thing in the message, but this is the raw data size collected from my database. It is not so big actually i guess.

    Loging at service or client side ?

    Your experience is build from the one of others
    Thursday, October 8, 2009 11:48 AM
  • At the service side.
    Thursday, October 8, 2009 11:50 AM
  • Hi Serge,

      It should be something wrong with your message size configeration.
     you can change them on your binding  configration.
    default setting as following:

    <binding name="BasicHttpBinding_ICentaMiddleService" closeTimeout="00:01:00"

              openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"

              maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"

              messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"


              <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"

                maxBytesPerRead="4096" maxNameTableCharCount="16384" />

              <security mode="None">

                <transport clientCredentialType="None" proxyCredentialType="None"

                  realm="" />

                <message clientCredentialType="UserName" algorithmSuite="Default" />


      you can update maxBufferSize,maxReceivedMessageSize ,maxArrayLength etc to a  larger one,
    such as 100,000,000,it is 100m.


    Frank Xu Lei--谦卑若愚,好学若饥
    Focus on Distributed Applications Development and EAI based on .NET
    欢迎访问老徐的中文技术博客:Welcome to My Chinese Technical Blog
    欢迎访问微软WCF中文技术论坛:Welcome to Microsoft Chinese WCF Forum
    欢迎访问微软WCF英文技术论坛:Welcome to Microsoft English WCF Forum
    Thursday, October 8, 2009 12:03 PM
  • I have log data on my service side and here is what I get :

    There was an error while trying to serialize parameter http://Maillefer.Nomos.Types.Interface/:GetAvailableRecipeResult.
    The InnerException message was 'Maximum number of items that can be serialized or deserialized in an object graph is '65536'.
    Change the object graph or increase the MaxItemsInObjectGraph quota. '.
    Please see InnerException for more details.
    Any idea what is that ?
    How can I increase this MaxItemsInObjectGraph ?

    Does this correspond to the architecture of item in my xml data ?

    thnaks for help
    Your experience is build from the one of others
    Thursday, October 8, 2009 12:27 PM
  • Hi,

    Set the following attribute to sufficietly large value like 1000000000.




    • Proposed as answer by Haripraghash Thursday, October 8, 2009 2:53 PM
    Thursday, October 8, 2009 12:42 PM
  • As you know data comes from my SQL database so I do not know in advance what will be the sise of this.
    Do I have to add this to all my services for safety or just the one which is afecting at the moment ?

    thnaks for help
    Your experience is build from the one of others
    Thursday, October 8, 2009 1:46 PM
  • If I set this behaviour has an attribute to my service in code. In case one day I need to increase it.
    Does that value which is set in config file can overright the value in code, or does the code is the effective value whtever you do in config file ?

    thnaks for help
    Your experience is build from the one of others
    Thursday, October 8, 2009 1:50 PM
  • I have increase this MaxItemsInObjectGraph value but it has to be set in both config file, client and service aotherwise it is not working

    Your experience is build from the one of others
    Thursday, October 8, 2009 2:12 PM