如何在WCF websocket duplex nethttpsbinding上启用gzip压缩

时间:2022-08-26 19:40:12

I would just like to enable gzip compression to the following binding.

我只想启用gzip压缩到以下绑定。

Here is what I have in my config file currently.

这是我目前在配置文件中的内容。

  <netHttpsBinding>
    <binding name="MutualCertificateBinding" maxReceivedMessageSize="9223372036854775807" receiveTimeout="00:20:00" sendTimeout="00:20:00" transferMode="Streamed" messageEncoding="Binary">
      <security mode="Transport">
        <transport clientCredentialType="Certificate" />
      </security>
      <webSocketSettings transportUsage="Always" />
    </binding>
  </netHttpsBinding>

According to MSDN tcp, http, and https in WCF are all capable of compression as of 4.5, I'm on 4.5.2.

根据MSDN tcp,WCF中的http和https都可以从4.5开始压缩,我在4.5.2。

Keep in mind I'm actually using a WCF contract with a callback contract so duplex is required.

请记住,我实际上正在使用带有回调合同的WCF合同,因此需要双工。

I'm happy to replace my binding with a custom binding as I control both sides and they are both .net but I've been unable to figure out how to create any custom binding that supports websockets.

我很高兴用自定义绑定替换我的绑定,因为我控制双方并且它们都是.net但我一直无法弄清楚如何创建支持websockets的任何自定义绑定。

Any help would be appreciated, thanks.

任何帮助将不胜感激,谢谢。

1 个解决方案

#1


0  

Okay I kept trying tons of different things and here is what I finally came up with and it's working. :)

好吧,我一直在尝试大量不同的东西,这就是我最终提出的并且它正在发挥作用。 :)

    <binding name="GZipMutualCertificateBinding" receiveTimeout="00:20:00" sendTimeout="00:20:00">
      <binaryMessageEncoding compressionFormat="GZip" />
      <httpsTransport maxReceivedMessageSize="9223372036854775807" requireClientCertificate="true" transferMode="Streamed">
        <webSocketSettings transportUsage="Always" />
      </httpsTransport>
    </binding>

This was found by trial and error, please let me know if you see anything that looks out of place. Thanks.

这是通过反复试验找到的,如果您发现任何看起来不合适的地方,请告诉我。谢谢。

#1


0  

Okay I kept trying tons of different things and here is what I finally came up with and it's working. :)

好吧,我一直在尝试大量不同的东西,这就是我最终提出的并且它正在发挥作用。 :)

    <binding name="GZipMutualCertificateBinding" receiveTimeout="00:20:00" sendTimeout="00:20:00">
      <binaryMessageEncoding compressionFormat="GZip" />
      <httpsTransport maxReceivedMessageSize="9223372036854775807" requireClientCertificate="true" transferMode="Streamed">
        <webSocketSettings transportUsage="Always" />
      </httpsTransport>
    </binding>

This was found by trial and error, please let me know if you see anything that looks out of place. Thanks.

这是通过反复试验找到的,如果您发现任何看起来不合适的地方,请告诉我。谢谢。