Search code examples
xsockets.net

XSocket.Longpolling fallback on MVC 3


Having some problems with this one.

MVC3, .NET 4.0, jQuery 1.11.0, XSockets 3.0

Client:

IE8 or Firefox(websocket=false)

<script src="jquery-1.11.0.min.js"></script>
<script src="jquery-migrate-1.2.1.min.js"></script>
<script src="json2.min.js"></script>
<script src="XSockets.fallback.latest.js"></script> 
<script src="XSockets.latest.js"></script>

$(function() {
        var conn = new XSockets.WebSocket("ws://127.0.0.1:4502/Generic");
        conn.onopen = function (connection) {
            // connection is open, subscribe to the 'foo' topic
            conn.on('foo', function (d) {
                //Data for the topic 'foo' arrived, add message to the page
                $('#content').append("<p>" + d + "</p>");
        });              
    };
});

Server:

IIS Express, Windows Authentication

routes.MapRoute(
      "Fallback",
      "{controller}/{action}",
      new { controller = "Fallback", action = "Init" },
      new[] { "XSockets.Longpolling" }
 );

Result:

"NetworkError: 404 Not Found - localhost:63360/Fallback/Init?url=ws%3A%2F%2F127.0.0.1%3A4502%2FGeneric%3FXSocketsClientStorageGuid%3D910d22f70cac4843832bd9f14ad9a549&storageGuid=&_=1401110430404"

image


Solution

  • You need MVC4 minimum for using the XSockets.NET longpolling fallback.

    And also... As of 4.0 XSockets.NET will remove the fallback for MVC and only support .NET 4.5 WebAPI fallback. The IIS8 option will also be removed and focus will be on using OWIN if not self-hosting XSockets.NET

    EDIT: typo