Reputation: 13791
I'm trying to configure my signalR demo to my project
framework : 4.0 , SignalR version : 1.1.3
Here's my code
$(function () {
var connection = $.hubConnection('http://localhost:32555/');
var chat = connection.createHubProxy('myChatHub');
chat.on('send', function (message) {
$('#chat').html($('#chat').html() + "\r\n" + message);
});
connection.logging = true;
connection.start().done(function () {
alert("Connection Complete");
$('#sendBtn').click(function () {
chat.invoke('send', $('#message').val());
});
}).fail(function (param) {
console.log(param);
});
});
Global.asax
protected void Application_Start(object sender, EventArgs e)
{
RouteTable.Routes.MapHubs(new HubConfiguration { EnableCrossDomain = true });
}
.Cs
namespace vPortal
{
[HubName("myChatHub")]
public class LetsChat : Hub
{
public void send(string message,string userid,string Name)
{
Clients.All.addMessage(message, userid, Name);
}
}
}
When I tried to run the page I got this error
SignalR: Error during negotiation request:
But, I have enabled proxy in the global.asax I have tried upgrading my signalR to version 2.2.3. But, my project packages are incompatible with the current version so I installed version 1.1.3.
I don't know what I'm doing wrong here I see there is a connection but can not establish.
Upvotes: 5
Views: 5822
Reputation: 13791
A lots of credit goes to this man. he made my problem easy to solve.
See, first of all my all the references were to 4.0 then So I used Signalr Older version 1.1.4
Here's is my errors scenario:
SignalR could not connect:
I removed this error by adding the lines RouteTable.Routes.MapHubs();
in my Global.asax file.
Negotiation of request: There was a silly mistake done by me the namespace was different in the my chat.aspx page.
Again,I was pretty sure about my code signalR will work fine:
So, run my chat and my first message was succeed then Again there was an error after sometime and the error was
the added or subtracted value results in an un-representable datetime. signlar
So, this was the big headache for me.This is definately nothing do with the signalR I got the clue from frebin and I realized that in my web.config
<httpRuntime executionTimeout="180" maxRequestLength="512000" />
The executionTimeout previous value was 9999999999
i changed to 180 and its works fine!!!
I have added all the scenarios for the future preferences.
Upvotes: 1