How to calculate size of message stream sending by WCF Server to client RRS feed

  • Question

  • From server side, sometimes we are sending very large data which is crossing the limit defined in NET TCP binding at client side. In such case we get the communication exception at client side. If i increase the size of binding parameter MaxReceivedMessageSize at client side, issue gets resolve but we are not sure how much data WCF server is going to send to us and it can again cross the limit defined in MaxReceivedMessageSize at client side.

    Is there any way through which i can get to know the actual size of message stream which is WCF server is going to send to client so that if size exceed against the size defined at client side so that before sending, i can trim the message contents at server side up to that limit.
    Thursday, January 14, 2016 9:30 AM


  • Hi jainarun85,

    According to this case, as far as I know, the message size is depend on the encoder being used

    and different encoder produced byte stream of different sizes.

    So you need to write a message Inspector to inspect the message size with different encoder.

    For more information, please refer to the following articles:

    1.Calculating WCF Message Size


    This response contains a reference 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.

    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.

    Friday, January 15, 2016 6:04 AM