IIS 7 and Above
Adapting a Native Module to handle the Websocket protocol (RFC6455) f...
Last post Oct 31, 2018 03:25 PM by rflsouza
Jun 21, 2012 12:32 PM|chrismunt|LINK
I am adapting an existing request handler (RQ_EXECUTE_REQUEST_HANDLER) implemented as a native module (C++) to handle the websocket protocol. I understand that this should be possible with IIS 8.
I have IIS 8 (Windows 8 Evaluation build 8400) and the latest RC for VS 2012 Professional. According to the documentation it should be possible to get a pointer to the IWebSocketContext interface from the IHttpContext of the request. The Iiswebsocket.h
header contains the definition for IWebSocketContext (apparently) but it appears to be missing from the distribution.
I have also downloaded the Windows 8 SDK (and all the stuff for .NET v4.5) on a Windows 7 system and the required header is not there either.
What do I need to download in order to get Iiswebsocket.h (and any associated code)?
Also, the mechanism for getting a pointer to the IWebSocketContext interface from the request's IHttpContext is not quite clear from the documentation so any information on this would be useful too.
Many thanks, in advance!
Aug 09, 2012 07:30 AM|chrismunt|LINK
Given that there was no response to the previous post, I decided to implement the Websockets protocol myself which, perhaps surprisingly, worked fine for extension modules implemented using the old ISAPI interface.
I programmatically handle the initial handshake in the extension code, then exchange data with the client over the websockets protocol using the following methods:
I handle the WebSockets data framing in the extension code. This scheme works well under ISAPI (even through the web sockets protocol is supposedly not supported for this generation of web servers).
However, the same scheme does not work for IIS v7 or v8 (for which websocket support IS supposed to be available). Again I handle the inital Websockets handshake then exhange data with the client
using the following methods:
Read: (IHttpRequest) ReadEntityBody()
Write: (IHttpResponse) WriteEntityChunks()
The Write operation works fine but the read does not. The ReadEntityBody function repeatedly returns 'end of data' even though the
client has sent data. It seems that once the initial request (to start a websocket) has been processed the ReadEntityBody() function doesn't even attempt to read further data from the client. I consider this to be a web server bug for both IIS v7 and IIS
Is there any way round this? Perhaps a lower-level function for directly reading data from the connected client?
Oct 31, 2018 03:25 PM|rflsouza|LINK
Could you give me an example of the implementation with the websocket in ISAPI?
I did the handshake but I do not know how to return and keep the connection.