I want to update my grid with latest alert messages added by Admin. I am using signalr and all hub related code I have added successfully.
It's also starting signalr connection but at the same time throwing below error
jquery.signalR-2.2.1.min.js:9 WebSocket connection to 'ws://localhost:58739/signalr/connect?transport=webSockets&clientProtocol=1.5&connectionToken=2h%2BQtKQ99bX%2Ffe8JT2UI1rbXQjfRYvt0MU9%2Fb7t6UzDpQcOGZ111owEUFVTQefgDA5EJ2e2C0HEHRRa%2BJSZ2Wz9rggWDARFiHUgdNihnhTlrpEw5fAK7v6wRfrkT1PiQ4VvxuHJRaIL3JxbxCs4tYlq%2F8qgAqA8UVNVB6e9CHkk%3D&connectionData=%5B%7B%22name%22%3A%22alertsmessageshub%22%7D%5D&tid=3' failed: Error during WebSocket handshake: net::ERR_CONNECTION_RESET
Below is script code in my view to update grid messages using signalr
$(function () {
debugger;
// Declare a proxy to reference the hub.
var notifications = $.connection.alertsMessagesHub;
//debugger;
// Create a function that the hub can call to broadcast messages.
notifications.client.updateMessages = function () {
getAllMessages()
};
// Start the connection.
$.connection.hub.start().done(function () {
alert("connection started")
getAllMessages();
}).fail(function (e) {
alert(e);
});
});
Here, in above code it's showing alert that Connection Started and also calling getAllMessages()
javascript method but then after in chrome development tool I am seeing above error.
Now, Below is my AlertsMessagesHub code
public static void SendMessages()
{
IHubContext context = GlobalHost.ConnectionManager.GetHubContext<AlertsMessagesHub>();
context.Clients.All.updateMessages();
}
Can anyone guide me what mistake I am doing or let me know if additional information required?
My .Net Target Framework is 4.5.1 and I am using signalr 2.2.1 and jquery : 2.1.4