How to get simple XSocket.Net example up and running

2.8k views Asked by At

Trying to follow the tutorials on how to set up a simple sample application. But I get an error when running the sample:

WebSocket connection to 'ws://127.0.0.1:41589/Generic' failed: Unexpected response code: 404

Not sure if it's my project or if it's chrome that failed.

Created a project: Create New Project Dialog

Runned in Nuget: Install-Package XSockets

And added a html file with the following code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script src="Scripts/jquery-1.9.1.js" type="text/javascript"></script>
    <script type="text/javascript" src="Scripts/XSockets.latest.js"></script>
    <script>

        $( document ).ready(function() {
            var url = "ws://127.0.0.1:41589/";
            var controller = "Generic";

            var ws = new XSockets.WebSocket(url + controller);

            ws.subscribe(XSockets.Events.open, function (connection) {
                console.log("This is your connection properties", connection);
            });
        });
    </script>
</head>
<body>

</body>
</html>

But when watching the console in Chrome by using Ctrl + Shift + j it gives the following message: Error message in Chrome

Web project setting was: web tab in Project settings

1

There are 1 answers

1
Uffe On BEST ANSWER

I think it may be the port-number that is wrong. The default port when you have installed the package should be 4502.

To get a full sample up´n running I can also recommend the sample packages XSockets.Sample.StockTicker for websockets or XSockets.Sample.WebRTC for a video-chat

If you are in a hurry with your XSockets.NET questions you can also join the developer forum