问题描述
我正在尝试在IIS 8中启用WebSocket-Extension permessage-deflate
,但到目前为止还没有运气。似乎IIS不支持任何扩展,并且不响应 Sec-WebSockets-Extension
标头。
我尝试通过 Response.Headers.Add(Sec-WebSockets-Extension,permessage-deflate; client_no_context_takeover; server_no_context_takeover)手动发送)
并在发送/接收之后通过 DeflateStream
进行压缩/解压缩,但随后WebSocket的接收方法失败。
我还试图手动将WebSocket实现为OWIN-Middleware(借助于库),但IIS不断关闭我的 InputStream
,无法读取数据。
有没有人成功启用此功能?
恐怕无法通过 System.Web.WebSockets
。
虽然您可以指示deflate模式的HTTP标头,但是消息需要激活RSV1位,以便识别为压缩:
因此,即使您压缩有效负载,由于消息头没有打开压缩位,接收器仍将尝试读取未压缩。一旦通过HTTP升级机制协商了deflate模式,您仍然可以将压缩和未压缩的消息一起发送,原因是deflate对于小有效负载无效,因此有些消息可能不值得压缩。 / p>
这就是说,既然ASP.NET中的WebSocket API不允许你计算出消息选项,我恐怕无法做到这一点。
现在,关于OWIN。我不得不说我没有探索过这条路,但是,我怀疑这是可能的,至少在与HTTP相同的端口中与IIS8集成,这可能就是你想要做的。
I am trying to enable the WebSocket-Extension permessage-deflate
in IIS 8, but with no luck so far. It seems, that IIS does not support any extensions and does not respond with an Sec-WebSockets-Extension
header.
I tried to send it manually via Response.Headers.Add("Sec-WebSockets-Extension", "permessage-deflate; client_no_context_takeover; server_no_context_takeover")
and did the compression/decompression via DeflateStream
by hand before sending/after receiving, but then the receive methods of the WebSocket failed.
I also tried to implement the WebSocket manually as an OWIN-Middleware (with the help of the library vtortola), but IIS keeps closing my InputStream
and reading of data is not possible.
Did anyone successfully enable this feature?
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:
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.
这篇关于IIS 8 WebSockets与permessage-deflate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!