none
WCF - Queries related to increasing binding property size on server and client side RRS feed

  • Question

  • Hi,

    I am getting below mentioned exception on client side when WCF server is trying to send data of around 2 MB:

    ERROR:

    System.ServiceModel.CommunicationException: The server did not provide a meaningful reply; this might be caused by a contract mismatch, a premature session shutdown or an internal server error.
    Server stack trace:

    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)


    WCF server and client both are at same machine and server is self hosted. On server side, we have configured named pipe binding without specifying any binding properties explicitly. On client side, we have configured net TCP binding and accessing WCF service through channel factory. We have set some net tcp binding properties on client side like: maxreceivedmessagesize, maxStringContentLength with value 1000000. 

    On client side, if increase value of maxreceivedmessagesize then this exception does not come. I have some queries related to same:

    1. I have increased size of binding property maxreceivedmessagesize on client side only and server does not contains any binding property then why this exception vanished? Does increasing size on this property on server side also matters? If yes then what is the difference increasing size on server vs client?

    2. I have increased size of one property maxreceivedmessagesize only and issue resolved. Does size of property maxStringContentLength also matters if yes then whats is the difference between these two properties? Apart from these properties, does size of other property also matter like: buffersize, bufferpoolsize etc if yes please expain in detail with simple example.

    3. If i increase size of these property does it affects performance of application on client or side like increasing RAM size or CPU size? If yes then what is the best practices when increasing the size of these parameter?

    4. I am not getting any good article or technical videos which can explain difference between different binding properties and difference between different protocol like: basichttp vs nettcp vs namedpipe with simple example. If someone has link for same please share the link. It would be very helpful for me.

    Sunday, January 17, 2016 6:42 AM

Answers

  • For#1, if you are not sending the same amount size of data back to the service, it doesn't matter on the service side.  It's a two way street on both sides, sending and receiving.

    For #2, if it blows up because one of the property sizes is too small, you'll know it.

    For #3, of course the memory size is going to increase as the data is in an object or object container like a List<T> and objects live in memory.   

    For #4, there are plenty of articles and tutorials by using Bing and Google you can find covering each one of the protocols for WCF examples. 

    Monday, January 18, 2016 12:02 AM

All replies

  • For#1, if you are not sending the same amount size of data back to the service, it doesn't matter on the service side.  It's a two way street on both sides, sending and receiving.

    For #2, if it blows up because one of the property sizes is too small, you'll know it.

    For #3, of course the memory size is going to increase as the data is in an object or object container like a List<T> and objects live in memory.   

    For #4, there are plenty of articles and tutorials by using Bing and Google you can find covering each one of the protocols for WCF examples. 

    Monday, January 18, 2016 12:02 AM
  • For #2, If i increase the size of parameter  maxreceivedmessagesize then proportionally how much size of maxStringContentLength should be increase? For example if i increase the size of maxreceivedmessagesize  to 20971520 (20 MB) then proportionally what will be size of parameter maxStringContentLength ?

    For #3,If i increase size of these property on client side but still getting small amount of data from server then does it affect performance because chances of getting big data of around 2 MB is 0.1% otherwise maximum time i'll get very less amount of data in KBs.

    • Edited by jainarun85 Monday, January 18, 2016 7:18 AM
    Monday, January 18, 2016 5:46 AM
  • For #2, If i increase the size of parameter  maxreceivedmessagesize then proportionally how much size of maxStringContentLength should be increase? For example if i increase the size of maxreceivedmessagesize  to 20971520 (20 MB) then proportionally what will be size of parameter maxStringContentLength ?

    You are hurting my head. I don't know, and you'll have to find out.

    For #3,If i increase size of these property on client side but still getting small amount of data from server then does it affect performance because chances of getting big data of around 2 MB is 0.1% otherwise maximum time i'll get very less amount of data in KBs.

    The only thing really being affected is transmission time, because of the amount being transmitted more amount is more time and lessamount is less time.. Just because you have a hole big enough to swallow a Mac truck, and you only send a Ford Pinto through the hole is it going to affect performance? The answer is no.

    Tuesday, January 19, 2016 4:51 AM
  • <clarification>

    The only thing really being affected is transmission time, because of the amount being transmitted more amount is more time and less amount is less time. Just because you have a hole big enough to swallow a Mac truck, and you only send a Ford Pinto through the hole is it going to affect performance of the hole and how the hole operates?  The answer is no.

    Tuesday, January 19, 2016 4:55 AM
  • increase size and increase timeout of binding instance, here is an example:

    new BasicHttpBinding
    {
    OpenTimeout = TimeSpan.FromMinutes(15),
    CloseTimeout = TimeSpan.FromMinutes(15),
    SendTimeout = TimeSpan.FromMinutes(15),
    ReceiveTimeout = TimeSpan.FromMinutes(15),
    MaxBufferPoolSize =
    int.MaxValue,
    MaxBufferSize =
    int.MaxValue,
    MaxReceivedMessageSize =
    int.MaxValue,
    ReaderQuotas = XmlDictionaryReaderQuotas.Max
    };

    for other kinds of binding is similar, if you use xml file to config binding, it is also similar, set all kinds of size to max

    Wednesday, January 20, 2016 9:24 PM
  • 1. I have increased size of binding property maxreceivedmessagesize on client side only and server does not contains any binding property then why this exception vanished? Does increasing size on this property on server side also matters? If yes then what is the difference increasing size on server vs client?

    2. I have increased size of one property maxreceivedmessagesize only and issue resolved. Does size of property maxStringContentLength also matters if yes then whats is the difference between these two properties? Apart from these properties, does size of other property also matter like: buffersize, bufferpoolsize etc if yes please expain in detail with simple example.

    3. If i increase size of these property does it affects performance of application on client or side like increasing RAM size or CPU size? If yes then what is the best practices when increasing the size of these parameter?

    4. I am not getting any good article or technical videos which can explain difference between different binding properties and difference between different protocol like: basichttp vs nettcp vs namedpipe with simple example. If someone has link for same please share the link. It would be very helpful for me

    Hi Jainarun85,

    For >> different protocol like: basichttp vs nettcp

    In WCF a particular binding does not necessarily imply a particular encoding. Various bindings

    can be configured to use various encodings. Net.TCP uses a binary encoding by default, and

    HTTP uses a text/xml encoding by default.

    With net.tcp your messages go sender -> net.tcp -> receiver.

    With HTTP they go from sender -> http -> tcp -> http -> receiver.

    There's an extra layer. The advantage of tcp is both of those: Both the extra layer and the

    default encoding.

    For your questions, I thought it relate to WCF optimization, here are some information about

    that, please refer to the following links:

    1.Optimizing WCF Web Service Performance

    2.Optimizing performance of your WCF Services

    ===========================================================

    This response contains two references to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.

    Hope it helps.

    Best Regards,

    Wanjun Dong


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate the survey.

    Sunday, January 24, 2016 9:30 AM
    Moderator