I try to play around websockets and implemented Websocket server as IHttpHandler. I'm, working on Windows8, VisualStudio 2012 and IIS 8 express. Everytime when I try to connect to my server using javascript client I get context.IsWebSocketRequest equals false inside ProcessRequest method. When I switch to local IIS server everything works fine (context.IsWebSocketRequest is true) . Did I miss something? How can I force IIS Express to work with WebSockets?
My WebSocket server implementation:
public class WebSocketHandler: IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
if (context.IsWebSocketRequest)
{
context.AcceptWebSocketRequest(ProcessWebSocketRequest,new AspNetWebSocketOptions()
{
RequireSameOrigin = true
});
}
}
private async Task ProcessWebSocketRequest(AspNetWebSocketContext socketContext)
{
var ws = socketContext.WebSocket;
while (true)
{
//Do something...
}
}
public bool IsReusable { get { return false; } }
}
Have you enabled the WebSockets in the configuration?
http://www.paulbatum.com/2011/09/getting-started-with-websockets-in.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.