asp.net - XSocket.Net - Error during WebSocket handshake: Unexpected response code: 404 -
i using xsocket.net real time communication in .net version 4.5.
i new xsocket.net.
the following tried. in controller folder created mycontroller following code.
using system; using xsockets.core.xsocket; using xsockets.core.xsocket.helpers; namespace xsockettest.controllers { public class mycontroller : xsocketcontroller { public void onchatmessage(string message) { this.sendto( message, "onchatmessage"); } } }
the following html page "index.html" in root location
<!doctype html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> </head> <body> <input type="text" id="input-message" value="goo lr" /> <button id="btn-send">send</button> <div id="messages"></div> <script src="scripts/jquery-2.1.0.min.js"></script> <script src="scripts/xsockets.latest.js"></script> <script> var conn = null; $(function () { //create connection conn = new xsockets.websocket('ws://localhost:4023/my'); conn.onopen = function () { conn.on('onchatmessage', function (d) { $('#messages').prepend($('<div>').text(d)); }); }; $('#btn-send').on('click', function () { conn.publish('onchatmessage', { message: $('#input-message').val() }); }); }); </script> </body> </html>
i getting error in console(chrome), on loading html, "websocket connection 'ws://localhost:4023/my' failed: error during websocket handshake: unexpected response code: 404"
i have no idea doing wrong.
any or sugggestions appreciated.
have started server?
my guess have added startup class (as described here see install webb-application).
then have html file in root, when requesting non-serverside resource app_start not called. in case initial request root , set breakpoint in startup class see fires. can go html file again.
just saw possible error, using port 4023, did start server on port? default port 4502, can ofcourse configure (see here)
edit: there error in controller. should not compile think. row:
this.sendto(message, "onchatmessage");
should be
this.sendtoall(message, "onchatmessage");
you can ofcourse use sento have pass in filter
func<t,bool>
Comments
Post a Comment