New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

The forum below will remain in read only mode.

Yay... Take Me to the Community!

Push notification with WebSockets

You are not authorized to post a reply.
Sort:
Declan Ward
New Member
New Member
Posts:9
Association Member
    I am attempting to implement WebSockets in a DNN Module.

    To see how WebSockets work I built a MVC application which works just fine.

    MVC Application
    By using an addin to Chrome, I can see that a socket is successfully opened:
    ws://localhost:12782/api/Websocket

    I then converted to IIS, rather than localhost, and after installing the WebSocket protocol in IIS this also works:
    ws://websockettest/api/Websocket

    Because I successfully opened the socket in the MVC application I thought replacing the host name + module name would work:

    ws://gg-dev/api/dwsWebSocketTest/Websocket

    Unfortunately not. I get an error:

    'ws://gg-dev2/api/dwsWebSocketTest/Websocket' failed: Error during WebSocket handshake: Unexpected response code: 404

    http://gg-dev2/API/dwsWeb...tTest/WebSocket/test

    responds from:
    [HttpGet]
    [ActionName("test")]
    [AllowAnonymous]
    public HttpResponseMessage HelloWorld()
    {
    return Request.CreateResponse(HttpStatusCode.OK, "Hello from WebSocketController!");
    }
    and I can trap this in the debugger. This suggess my url is correct.

    Testing the socket does not get to my code. I have tried with & without the decoration:
    //[HttpGet]
    //////[ValidateAntiForgeryToken]
    //[ActionName("get")]
    //[AllowAnonymous]
    //[DnnModuleAuthorize(AccessLevel = SecurityAccessLevel.Anonymous)]
    public HttpResponseMessage Get()
    {
    if (HttpContext.Current.IsWebSocketRequest)
    {
    var commentHandler = new CommentSocketHandler();
    HttpContext.Current.AcceptWebSocketRequest(commentHandler);
    }

    return new HttpResponseMessage(HttpStatusCode.SwitchingProtocols);
    }

    Do I need to do something in DNN to get this to work, or am I missing something obvious?

    All suggestions welcomed!
    You are not authorized to post a reply.

    Hosting liberally provided by