IIS 8 WebSockets with permessage-deflate

让人想犯罪 __ 提交于 2019-12-03 16:18:41

I am afraid it is not possible through System.Web.WebSockets.

https://tools.ietf.org/html/rfc7692#section-6

Although you can indicate the HTTP headers for the deflate mode, the messages need to have activated the bit RSV1 in order to be identified as compressed:

This document allocates the RSV1 bit of the WebSocket header for PMCEs and calls the bit the "Per-Message Compressed" bit. On a WebSocket connection where a PMCE is in use, this bit indicates whether a message is compressed or not.

So even if you compress the payload, since the message header does not have the compression bit on, the receiver will still try to read as uncompressed. Once you negotiated the deflate mode through the HTTP upgrade mechanism, you can still send compressed and uncompressed messages together, and the reason for this is that deflate is not effective with small payloads, so there are messages that may not be worth to compress.

That said, since the WebSocket API in ASP.NET does not allow you to work out the message options, I am afraid this cannot be done.

Now, about OWIN. I have to say I have not explored this path, however, I doubt that is possible, at least integrated with IIS8 in the same port than HTTP, that is probably what you want to do.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!