3

I am trying to implement compression for our WCF service, using a netTCP endpoint. I've read almost all the developer network posts, and the posts on SO, to no avail.

How does one configure the client endpoint CompressionFormat (See compression and the binary encoder) property? Is this in fact necessary when you've added a service reference in VS to get the generated endpoints?

I've done the standard config of the endpoint in the server app.config file:

<customBinding>
    <binding name="tcpCompression">
     <windowsStreamSecurity protectionLevel="None"/>
     <binaryMessageEncoding compressionFormat="GZip"/>
     <tcpTransport/>
    </binding>
...
</customBinding>

And I can make a call from the client using this endpoint.

This is the client endpoint:

Edit: I've changed the binding used on the client to implement compression on the client side as well:

<endpoint 
  address="net.tcp://localhost:8734/Quasar/QuasarService"
  binding="customBinding" 
  bindingConfiguration="netTcpCompression"
  contract="Quasar.IQuasarService" 
  name="CustomBinding_IQuasarService">
  <identity>
    <userPrincipalName value="foo@bar.com" />
  </identity>
</endpoint>

<customBinding>
  <binding name="netTcpCompression">
    <windowsStreamSecurity protectionLevel="None"/>
    <binaryMessageEncoding compressionFormat="GZip"/>
    <tcpTransport maxReceivedMessageSize="1000000"/>
  </binding>
</customBinding>
monkeydeus
  • 395
  • 1
  • 4
  • 15
  • It looks like your binding needs to be wrapped in a tag. Have you tried this? – flacnut Aug 29 '13 at 01:03
  • It looks like you are using .net < 4.5. Microsoft did not expose the compression features through the standard bindings until .net 4.5. – Aron Aug 29 '13 at 05:23
  • @sheldo: Yes, I omitted the tag because it is encapsulating a few other bindings, but it is there. Thanks. – monkeydeus Aug 29 '13 at 15:20
  • @Aron This is currently a 4.5 app, but it was started as a 4.0 service. The only change I needed to make, AFAIK, was adding the compressionFormat attribute to the binaryMessageEncoding. What gave this away as a 4.0 app? At any rate, it is 4.5 now, so compression should be available, unless I am missing something else. – monkeydeus Aug 29 '13 at 15:31
  • I've partially answered my own question: it is a matter of configuring a binding on the client endpoint. I was under the mistaken impression that using the metadata to create a client endpoint would leverage the compression configured on the server side. I am still working on a way to verify the compression, so, can't say for sure that the client endpoint is working correctly, but at least now I know how it is *supposed* to be enabled on the client. – monkeydeus Sep 06 '13 at 15:35

0 Answers0