SignalR - connection.hubName is undefined

Related searches

I have the following SignalR hub class (only the top is shown):

public class DataServiceHub : Hub, IDataServiceHub, IDisconnect, IConnected

I'm then self hosting the hub in a Console App using the following code in Main function:

string hubsUrl = appSettingsReader.GetValue("hubsUrl", typeof(string)).ToString();
var hubsServer = new Server(hubsUrl);
hubsServer.Configuration.DisconnectTimeout = TimeSpan.Zero;

The values of hubsUrl is "http://localhost:4322/"

Once I've run up the Console App If I browse in Chrome "http://localhost:4322/signalr/hubs" I can see the SignalR javascript and my hub at the bottom:

signalR.dataServiceHub = {
    _: {
        hubName: 'dataServiceHub',

I'm trying to connect to this hub from an MVC3 app running on a HTTPS/SSL setup (i.e. the site url prefix is "https://localhost/"

In my Razor page I definately include the SignalR js:

<script src="/Website/Scripts/kendo/2012.2.710/jquery.min.js" type="text/javascript"></script>
<script src="/Website/Scripts/jquery.signalR-0.5.3.min.js" type="text/javascript"></script>
<script src="http://localhost:4322/signalr/hubs" type="text/javascript"></script>

Note that we're using Kendo so the jquery js include is via that.

Then in the $(document).ready(function () { I have the following: = true;
var connection = $.hubConnection('http://localhost:4322');
var hub = connection.dataServiceHub;

But 'hub' is always 'undefined'.

What am I missing here?

If this is cross domain problem - how do I resolve it?

Hubs have 2 programming models and you're mixing them:


If you scroll to the bottom of those pages, there's an example that shows you what you need to do to use cross domain in each of the models.

$.connection.(hubname) undefined, "var chat = $ chat. connection.chatHub," the variable i is always "undefined. Jquery libraries and singnalR load successfully. the path "~ / signalr� Re: $.connection.(hubname) undefined Jun 08, 2013 12:12 AM | riteshtandon23 | LINK I was also facing the same problem, The problem was that i was using the dlls of old SignalR version, Then i updated my SignalR files from NuGet and the problem was solved.

make sure that you are referencing jquery 1.6.4

$.hubConnection is undefined, $.connection is undefined signalr cannot read property 'client' of undefined signalr signalr (hubname) undefined, chatHub," the variable i is always " undefined. We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand

Check in your global.asax file, if the line routes.Clear(); is present there, please remove that line because it will clear signal routes.

ASP.NET SignalR Hubs API Guide, For an introduction to SignalR, Hubs, and Persistent Connections, see If you decorate your Hub class with a HubName attribute, use the� $.connection.hubname is undefined. Member 14200962 6-Apr-19 0:24. Member 14200962: if yes, it is TOO bad, I would understand SignalR server side be ASP & IIS,

If you using https don't specify url neither through argument nor via 'url'-property in case when your hub working on the same url. Your hub, otherwise, will be undefined.


I screwed up guys. I was so hurry to post about specific behavior I 've just detected so I had no check out any possible version more.

However there was a bug in application that provides wrong url to hub with another port than was needed. therefore switching off property setting url for hub proxy has made my client workly.

watch for links your application provides...

.NET SignalR Error: Cannot read property 'client' of undefined, SignalR { [HubName("dashboardHub")] public class DashboardHub : Hub { public void sendMessage(string message) { Clients.All.receiveMessage(notes); } � "TypeError: <hubType> is undefined" error This error will result if the call to MapSignalR is not made properly. See How to register SignalR Middleware and configure SignalR options for more information.

SignalR Can not read property 'MyHub' of undefined, AspNet.SignalR;usingMicrosoft.AspNet.SignalR.Hubs;namespaceZaniADV{[ HubName("MyHub")] public class MyHub : Hub { public static void�

  • My understanding is that the HubName parameter should start with lower case, to match the client name: "dataServiceHub", not "DataServiceHub". (But then I'm having a problem similar to the above, so I'm certainly no authority.)
  • This page is relevant, since it can produce the "failed to export hub name" symptom by causing MapSignalR to fail, due to a mismatch in NuGet packages. (This turned out to be my problem.)
  • Hi, I've actually updated the code since then and tried both. So I now have: $.connection.hub.url = 'localhost:4322/signalr' followed by var hub = $.connection.dataServiceHub; but still the hub is undefined
  • Another note: If I host the same hub class on another web project we have (which is on the same localhost domain) then the same javascript client code works (with the only change being the url set for the $.connection.hub.url).
  • You can just look at the generated script in the remote project and see if the hub got generated or not localhost:4322/signalr/hubs.
  • if you mean load up that url in a browser then yes the hub has been generated - I put the output from that part in the first post.
  • If you put all the pieces together you can figure out why it's undefined. When you include that script, it declares a global $.connection.hub on the page and $.connection.hub1..hubn, as properties. If you look at the generated script, you can clearly see the members that exists on the $.connection object and that should give you a clue as to what is going wrong.
  • Pranav, that's not really a complete enough answer. Can you please try to improve it to be more helpful to the OP?
  • I'm referencing jquery 1.7.1 (via the inclusion of Kendo stuff). This page has also worked against a different SignalR hub and no changes have been made to the javascript includes.
  • This is nothing to do with jQuery. See my answer below