I've had this same SignalR Hub for years now so I've upgraded it and now for some reason it is not generating the client proxies.
Has anyone else run into this issue?
I've updated to the most resent version.
None of my client methods are being generated for some reason, I've tried everything and it must be a new setting that I am missing.
When I first started using SignalR it was a stand alone library now it is integrated with the .NET platform this leads me to believe I have not set something up correctly.
Here is what I've done before I release my solution I've worked on it so long I've got libraries that are 2.0 so I've upgraded all of them to 4.6.2 and this of course has caused a lot of breakage but I have read the docs and it still states I should be able
to
http://localhost:2488/signalr/hubs
and see the client and server methods but the client methods just show an empty array [].
I've got code to help you better understand.
/*!
* ASP.NET SignalR JavaScript Library v2.2.1
* http://signalr.net/
*
* Copyright (c) .NET Foundation. All rights reserved.
* Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
*
*/
/// <reference path="..\..\SignalR.Client.JS\Scripts\jquery-1.6.4.js" />
/// <reference path="jquery.signalR.js" />
(function ($, window, undefined) {
/// <param name="$" type="jQuery" />
"use strict";
if (typeof ($.signalR) !== "function") {
throw new Error("SignalR: SignalR is not loaded. Please ensure jquery.signalR-x.js is referenced before ~/signalr/js.");
}
var signalR = $.signalR;
function makeProxyCallback(hub, callback) {
return function () {
// Call the client hub method
callback.apply(hub, $.makeArray(arguments));
};
}
function registerHubProxies(instance, shouldSubscribe) {
var key, hub, memberKey, memberValue, subscriptionMethod;
for (key in instance) {
if (instance.hasOwnProperty(key)) {
hub = instance[key];
if (!(hub.hubName)) {
// Not a client hub
continue;
}
if (shouldSubscribe) {
// We want to subscribe to the hub events
subscriptionMethod = hub.on;
} else {
// We want to unsubscribe from the hub events
subscriptionMethod = hub.off;
}
// Loop through all members on the hub and find client hub functions to subscribe/unsubscribe
for (memberKey in hub.client) {
if (hub.client.hasOwnProperty(memberKey)) {
memberValue = hub.client[memberKey];
if (!$.isFunction(memberValue)) {
// Not a client hub function
continue;
}
subscriptionMethod.call(hub, memberKey, makeProxyCallback(hub, memberValue));
}
}
}
}
}
$.hubConnection.prototype.createHubProxies = function () {
var proxies = {};
this.starting(function () {
// Register the hub proxies as subscribed
// (instance, shouldSubscribe)
registerHubProxies(proxies, true);
this._registerSubscribedHubs();
}).disconnected(function () {
// Unsubscribe all hub proxies when we "disconnect". This is to ensure that we do not re-add functional call backs.
// (instance, shouldSubscribe)
registerHubProxies(proxies, false);
});
proxies['alumChatHub'] = this.createHubProxy('alumChatHub');
proxies['alumChatHub'].client = {};
proxies['alumChatHub'].server = {
addMeNewbie: function (Attendee) {
return proxies['alumChatHub'].invoke.apply(proxies['alumChatHub'], $.merge(["addMeNewbie"], $.makeArray(arguments)));
},
getChatRooms: function () {
return proxies['alumChatHub'].invoke.apply(proxies['alumChatHub'], $.merge(["getChatRooms"], $.makeArray(arguments)));
},
getDirectMsgForNotify: function () {
return proxies['alumChatHub'].invoke.apply(proxies['alumChatHub'], $.merge(["getDirectMsgForNotify"], $.makeArray(arguments)));
},
leaveAlumCloudChat: function (roomid, alias, isPro) {
return proxies['alumChatHub'].invoke.apply(proxies['alumChatHub'], $.merge(["leaveAlumCloudChat"], $.makeArray(arguments)));
},
sendChat: function (alumCloudMsg) {
return proxies['alumChatHub'].invoke.apply(proxies['alumChatHub'], $.merge(["sendChat"], $.makeArray(arguments)));
},
sendDirectMsg: function (alumCloudMsg) {
return proxies['alumChatHub'].invoke.apply(proxies['alumChatHub'], $.merge(["sendDirectMsg"], $.makeArray(arguments)));
},
sendPrivateChat: function (alumCloudMsg) {
return proxies['alumChatHub'].invoke.apply(proxies['alumChatHub'], $.merge(["sendPrivateChat"], $.makeArray(arguments)));
},
subscribeAlumCloudChat: function (attendee) {
return proxies['alumChatHub'].invoke.apply(proxies['alumChatHub'], $.merge(["subscribeAlumCloudChat"], $.makeArray(arguments)));
}
};
proxies['collaboratorHub'] = this.createHubProxy('collaboratorHub');
proxies['collaboratorHub'].client = {};
proxies['collaboratorHub'].server = {
addMeNewbie: function (Attendee) {
return proxies['collaboratorHub'].invoke.apply(proxies['collaboratorHub'], $.merge(["addMeNewbie"], $.makeArray(arguments)));
},
sendChat: function (cmsg) {
return proxies['collaboratorHub'].invoke.apply(proxies['collaboratorHub'], $.merge(["sendChat"], $.makeArray(arguments)));
},
sendCollaborate: function (collaboratorsUpdate) {
return proxies['collaboratorHub'].invoke.apply(proxies['collaboratorHub'], $.merge(["sendCollaborate"], $.makeArray(arguments)));
},
subscribePartManager: function () {
return proxies['collaboratorHub'].invoke.apply(proxies['collaboratorHub'], $.merge(["subscribePartManager"], $.makeArray(arguments)));
},
unSubscribePartManager: function () {
return proxies['collaboratorHub'].invoke.apply(proxies['collaboratorHub'], $.merge(["unSubscribePartManager"], $.makeArray(arguments)));
}
};
return proxies;
};
signalR.hub = $.hubConnection("/signalr", { useDefaultPath: false });
$.extend(signalR, signalR.hub.createHubProxies());
}(window.jQuery, window));
You'll notice that the proxies for the client is
proxies['alumChatHub'].client = {}; EMPTY
Here is my start
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Owin;
using Owin;
[assembly: OwinStartup(typeof(AlumCloud.Startup))]
namespace AlumCloud
{
public partial class Startup
{
public void Configuration(IAppBuilder app)
{
ConfigureAuth(app);
app.MapSignalR();
}
}
}
Here is my Hub
using System;
using System.Collections.Generic;
using System.Web;
using Microsoft.AspNet.SignalR;
using System.Threading.Tasks;
using WebChat.Logic;
using System.Web.Security;
using System.Configuration;
using ChatDL;
using ChatDL.DataTransfer.Tables;
using ChatBL;
namespace AlumCloud.hubs
{
public class AlumChatHub : Hub
{
public static string _cnnMessaging = ConfigurationManager.ConnectionStrings["_messaging"].ConnectionString;
public async Task<List<SharedMessage>> sendChat(AlumCloudMsg alumCloudMsg)
{
alumCloudMsg.cnnid = Context.ConnectionId;
//DateTime dtSince = DateTime.Now;
//DateTime.TryParse(alumCloudMsg.Since.ToString(), out dtSince);
List<ChatDL.Message> messages = new List<ChatDL.Message>();
//Guid uid = new Guid(Membership.GetUser().ProviderUserKey.ToString());
//if (dtSince.Year == 1)
//{
// dtSince = DateTime.Now.Subtract(new TimeSpan(0, 2, 0));
//};
///if (isPriv)
// {
//List<uspGetPirvateMessage_Result> pmsgLst = ChatManager.RecievePrivateMessage(uid, alumCloudMsg.RoomID, dtSince);
//if (pmsgLst != null)
//{
// foreach (uspGetPirvateMessage_Result msg in pmsgLst)
// {
// messages.Add(new Message(msg));
// }
// alumCloudMsg.privateMsgs.AddRange(messages);
//}
// }
// else
// {
//ChatManager.SendPrivateMessage(cm.msg, cm.roomid, cm.toid, cm.fromid, cm.inReplyid, out newMessageID);
InsertNewID insertedNewID = await ChatManagerBL.SendChatMessageAsync(_cnnMessaging, new Guid(Membership.GetUser().ProviderUserKey.ToString()), alumCloudMsg.RoomID, alumCloudMsg.msg);
SharedMessage msg = await ChatManagerBL.GetChatMessageByIdAsync(_cnnMessaging, insertedNewID.NewInsertedID,/*need to make a proc that does not require the userid because it is not needed here*/ new Guid(Membership.GetUser().ProviderUserKey.ToString()));
List<SharedMessage> msgLst = new List<SharedMessage>(1);
msgLst.Add(msg);
if (msgLst != null)
{
alumCloudMsg.msgs = new List<ChatDL.Message>(1);
alumCloudMsg.msgs.Add(new ChatDL.Message(msgLst[0]));
}
return Clients.Group(alumCloudMsg.RoomID.ToString()).receiveMsg(alumCloudMsg);
}
public async Task<InsertNewID> sendPrivateChat(AlumCloudMsg alumCloudMsg)
{
alumCloudMsg.cnnid = Context.ConnectionId;
List<ChatDL.Message> messages = new List<ChatDL.Message>();
InsertNewID newInsertedID = await ChatManagerBL.SendChatPrivateMessageAsync(_cnnMessaging, alumCloudMsg.msg, alumCloudMsg.RoomID, new Guid(alumCloudMsg.toid), new Guid(alumCloudMsg.fromid), alumCloudMsg.inReplyid);
SharedMessage msg = await ChatManagerBL.GetChatRoomPrivateMessage_ByIDAsync(_cnnMessaging, newInsertedID.NewInsertedID,/*need to make a proc that does not require the userid because it is not needed here*/ new Guid(Membership.GetUser().ProviderUserKey.ToString()), alumCloudMsg.RoomID);
List<SharedMessage> msgLst = new List<SharedMessage>(1);
msgLst.Add(msg);
if (msgLst != null)
{
alumCloudMsg.msgs = new List<ChatDL.Message>(1);
alumCloudMsg.msgs.Add(new ChatDL.Message(msgLst[0]));
}
var clients = new List<string>();
clients.Add(alumCloudMsg.tocnnid);
clients.Add(this.Context.ConnectionId);
return Clients.Clients(clients).receiveMsg(alumCloudMsg);
}
Anywhere you see Clients.Client it does not generate anything.
I realize the return is not necessary but I just recently put it there to see if that would work and it does not, actually I added a return Task type and the return and the bottom of the function but it has never been there before,
it put it there just for a shot in the dark.
PLEASE HELP ME WITH THIS I AM STUCK AT A POINT THAT I CANNOT MOVE FORWARD UNTIL THIS IS WORKING, DUE TO THE FACT THAT MY SOLUTION HEAVLY RELIES ON SignalR.
Thanks to anyone to help me.
I have not done anything to the config files or global file, added anything unusual, I am using it as if it was the very first version that was released, so I am missing something.
HELPPPPPPPPPPPPPPPPPPPPPPP.!!!
Erik Little
AlumCloud
Full Stack Developer
469-540-8417
Skype: erik@alumcloud.com
It has been a while since I've worked with SignalR and I forgot that SignalR does to create Client side code, the code that calls the server.
It is up to the developer to make sure that function signature on the client side and the server side matches in order for it to work or it will throw an error.
This is a no brainier, but it has been a few years and I am refactoring before i go into production, some of my class libraries were 2.0 but every library / web is the lastest 4.6.2 or 4.5.2.
Do you have a good tool that you can recommend to me to test JSON / AJAX calls from the browser? Like an extension or some other product that I can use with Firefox -> Web Api -> work
Throw new Exception("My Exception Info",ex); error -> Web Api -> FireFox <------- I need this to come back to the browser for testing. It will throw but not back to the browser.
I only use Firefox and IE right now because Google has made some policy changes that are a Hackers dream and they may not realize this but allowing an app from foreign phone or computer to use your phone or computer "Even though it is not on or connected
to be used as a pass-though for a connection or using your devices as a connection point it-self is UNBELIEVABLE" 99.9% of all android users and windows 10 users with Google Chrome do not know the seriousness of this"
Anyway, i wanted to add that because I want this information out on the internet.
**I'm using the latest version of SignalR 2.2.1
Thank you so much for your help.
Erik Little
AlumCloud
Full Stack Developer
469-540-8417
Skype: erik@alumcloud.com
You could use fiddler to test the request/ response . You could debug the application and use exception filters to handle runtime errors in your Web API :
Member
3 Points
6 Posts
SignalR Client Proxies are not being Created
Sep 16, 2016 05:01 PM|alumcloud|LINK
I've had this same SignalR Hub for years now so I've upgraded it and now for some reason it is not generating the client proxies.
Has anyone else run into this issue?
I've updated to the most resent version.
None of my client methods are being generated for some reason, I've tried everything and it must be a new setting that I am missing.
When I first started using SignalR it was a stand alone library now it is integrated with the .NET platform this leads me to believe I have not set something up correctly.
Here is what I've done before I release my solution I've worked on it so long I've got libraries that are 2.0 so I've upgraded all of them to 4.6.2 and this of course has caused a lot of breakage but I have read the docs and it still states I should be able to
and see the client and server methods but the client methods just show an empty array [].
I've got code to help you better understand.
You'll notice that the proxies for the client is
Here is my start
Here is my Hub
Anywhere you see Clients.Client it does not generate anything.
I realize the return is not necessary but I just recently put it there to see if that would work and it does not, actually I added a return Task type and the return and the bottom of the function but it has never been there before, it put it there just for a shot in the dark.
PLEASE HELP ME WITH THIS I AM STUCK AT A POINT THAT I CANNOT MOVE FORWARD UNTIL THIS IS WORKING, DUE TO THE FACT THAT MY SOLUTION HEAVLY RELIES ON SignalR.
Thanks to anyone to help me.
I have not done anything to the config files or global file, added anything unusual, I am using it as if it was the very first version that was released, so I am missing something.
HELPPPPPPPPPPPPPPPPPPPPPPP.!!!
AlumCloud
Full Stack Developer
469-540-8417
Skype: erik@alumcloud.com
Where Technology meets the Building Industry!
All-Star
18265 Points
3594 Posts
Microsoft
Re: SignalR Client Proxies are not being Created
Sep 19, 2016 06:45 AM|Nan Yu|LINK
Hi alumcloud ,
Do you update the signalR to version 2 ? . For details on changes between SignalR 1.x and 2, seeUpgrading SignalR 1.x Projects and Visual Studio 2013 Release Notes. Troubleshooting errors encountered during upgrading , you could see SignalR Troubleshooting.
Best Regards,
Nan Yu
MSDN Community Support
Please remember to "Mark as Answer" the responses that resolved your issue.
Member
3 Points
6 Posts
Re: SignalR Client Proxies are not being Created
Sep 19, 2016 03:34 PM|alumcloud|LINK
It has been a while since I've worked with SignalR and I forgot that SignalR does to create Client side code, the code that calls the server.
It is up to the developer to make sure that function signature on the client side and the server side matches in order for it to work or it will throw an error.
This is a no brainier, but it has been a few years and I am refactoring before i go into production, some of my class libraries were 2.0 but every library / web is the lastest 4.6.2 or 4.5.2.
Do you have a good tool that you can recommend to me to test JSON / AJAX calls from the browser? Like an extension or some other product that I can use with Firefox -> Web Api -> work
Throw new Exception("My Exception Info",ex); error -> Web Api -> FireFox <------- I need this to come back to the browser for testing. It will throw but not back to the browser.
I only use Firefox and IE right now because Google has made some policy changes that are a Hackers dream and they may not realize this but allowing an app from foreign phone or computer to use your phone or computer "Even though it is not on or connected to be used as a pass-though for a connection or using your devices as a connection point it-self is UNBELIEVABLE" 99.9% of all android users and windows 10 users with Google Chrome do not know the seriousness of this"
Anyway, i wanted to add that because I want this information out on the internet.
**I'm using the latest version of SignalR 2.2.1
Thank you so much for your help.
AlumCloud
Full Stack Developer
469-540-8417
Skype: erik@alumcloud.com
Where Technology meets the Building Industry!
All-Star
18265 Points
3594 Posts
Microsoft
Re: SignalR Client Proxies are not being Created
Sep 20, 2016 03:03 AM|Nan Yu|LINK
Hi ,
You could use fiddler to test the request/ response . You could debug the application and use exception filters to handle runtime errors in your Web API :
http://www.infoworld.com/article/2994111/application-architecture/how-to-handle-errors-in-web-api.html
Best Regards,
Nan Yu
MSDN Community Support
Please remember to "Mark as Answer" the responses that resolved your issue.