none
WCF compressed message size RRS feed

  • Question

  • I am using WCF 4.5 GZip compression over tcp and I have following binding. 

        <customBinding>
                <binding name="TcpBinaryCompressionBinding" >
                  <binaryMessageEncoding compressionFormat="GZip"/>
                  <windowsStreamSecurity protectionLevel="EncryptAndSign" />
                  <tcpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxBufferPoolSize="2147483647">
                     
                  </tcpTransport>
                  
                </binding>
        </customBinding>

    I want to get the actual message size on the wire and for that I have written a custom encoder. 
    The custom encoder is getting called but it throws "QuoteExceededException" in the Encoder's ReadMessage method

    To get to the bottom of the problem I have commented out everything in this method and just forwarding the ReadMessage call to the inner encoder 

        public override Message ReadMessage(ArraySegment<byte> buffer, BufferManager bufferManager, string contentType)
                {            
                    return _innerMessageEncoder.ReadMessage(buffer, bufferManager, contentType);
                }

    But still I am getting the same exception. Note that the same encoder works with NetTcpBinding. It must be something to do with binaryMessageEncoder with GZIP. 

    Also, is there any other way I could measure the message size before compression and after compression without using custom encoder. Note that I have to use TCP binding. 
    Thursday, August 11, 2016 2:15 PM

Answers