1
votes

I'm starting with signalr but got some trouble, my test server run at http://localhost:22660/ and my web run at http://localhost:61963/.I got this error when connect from client to server:

GET http://localhost:61963/signalr/negotiate?clientProtocol=1.4&connectionData=%5B%7B%22name%22%3A%22chathub%22%7D%5D&_=1496809403215 404 (Not Found)

I already config: $.connection.hub.url = 'http://localhost:22660/signalr'; but not work, this my js code:

var connection = $.hubConnection();
$.connection.hub.url = 'http://localhost:22660/signalr';
var chatHub = connection.createHubProxy('ChatHub');
connection.start()
    .done(function () { console.log('Now connected, connection ID=' + connection.id); })
    .fail(function () { console.log('Could not connect'); });

Server:

namespace test
{
public class Startup
{
    public void Configuration(IAppBuilder app)
    {
        app.Map("/signalr", map =>
        {
            map.UseCors(CorsOptions.AllowAll);
            var hubConfiguration = new HubConfiguration
            {
                EnableJSONP = true
            };
            map.RunSignalR(hubConfiguration);
        });
    }
}
}
namespace SignalRChat
{
public class ChatHub : Hub
{
    public void Send(string name, string message)
    {
        // Call the addNewMessageToPage method to update clients.
        Clients.All.addNewMessageToPage(name, message);
    }
}
}
1
Your web what runs on localhost:61963 ? Please see minimal reproducible example, and follow the guidelines there - J.N.
it just empty .NET website with index.hmtl and jquery, signalr lib included - JimmyN
Please post the serverside code of the hub, and where you register the hub. - J.N.
@J.N. Just added - JimmyN

1 Answers

1
votes

I dont sure, but i think because i using different version of signalr (2.1.2 and 2.2.0). Using same version solved my problem.