25

I use SignalR 2.2.0 in a MVC5 project. SignalR depends of JQuery in client-side.

JQuery recently released new version, I updated it from Nuget, specifically from version 2.2.4 to 3.0.0.1, but then SignalR stopped working. Startup command "$.connection.hub" in javascript fails. After a long time head scratching, I downgrade JQuery to 2.2.4 and everything is fine again.

Am I the only one getting this problem? There is any workaround?

Thanks.

2
  • I'm having the same problem; but worse. Upgrading jQuery from 1.11.x to 3.4.1. Have many breaking changes and most of them are coming from other dependencies Commented May 16, 2019 at 5:28
  • @SenuraDissanayake Try upgrading everything... Now I'm currently using SignalR 2.4.1 and still JQuery 3.3.1, got no problems upgrading since that one.
    – TNT
    Commented May 16, 2019 at 11:57

3 Answers 3

22

Finally version 2.2.1 of SignalR was released, solving this problem. Thanks for all comments.

4
  • interestingly no mention of jQuery 3 in the release notes but here they are anyway : github.com/SignalR/SignalR/releases Commented Aug 16, 2016 at 3:24
  • 1
    looking at jquery.signalR-2.2.1.js. I still find jQuery.fn.unbind() for example. I don't think that singalR 2.2.1 is yet fully ready for jquery 3
    – gsharp
    Commented Jan 5, 2017 at 10:19
  • 2
    Version 2.2.2 seems to cure this, its compatible with Jquery 3.1.1 as it comes. Commented Jul 25, 2017 at 15:29
  • Thanks a lot for documenting your solution! I spent 4 days full-time to investigate the issue... Originally I assumed, the server-side is broken.
    – StrictLine
    Commented Sep 12, 2023 at 12:33
21

You must edit the signalR code by yourself, In jquery 3 they removed the shortcut for load event :

Breaking change: .load(), .unload(), and .error() removed

These methods are shortcuts for event operations, but had several API limitations. The event .load() method conflicted with the ajax .load() method. The .error() method could not be used with window.onerror because of the way the DOM method is defined. If you need to attach events by these names, use the .on() method, e.g. change $("img").load(fn) to $(img).on("load", fn).

https://jquery.com/upgrade-guide/3.0/

so in the file jquery.signalR-{version}.js :

you must update this line :

_pageWindow.load(function () { _pageLoaded = true; });

To :

_pageWindow.on("load",function () { _pageLoaded = true; });
3
  • Worked for me, also. Commented Jul 4, 2016 at 10:08
  • 2
    SignalR developers must make this change now. Commented Jul 14, 2016 at 15:43
  • I had this problem in version 1.2.2 and this worked for me. thanks!
    – eaglei22
    Commented May 24, 2017 at 15:57
1

If you're still getting errors like this after updating to 2.2.1 and jQuery 3.x then read on...

TypeError: Cannot read property 'client' of undefined

Like I am you are probably using the dynamically generated proxy, and you checked your /signalr/hubs file and found you don't have any proxies defined.

 var proxies = {};

Wait you may ask I didn't change anything - where did they go?

Well, like me you probably were in such a hurry to upgrade signalR to 2.2.1 that you forgot to do it in all your projects and now you are using both 2.2.1 and 2.2.0 in different assemblies. (I am defining my hubs in a different assembly than my main app).

All I needed to do was make sure I had the latest nuget package version in every project and it all worked. Should work fine after rebuilding. If not, this may also help.

Also do yourself a favor and read the jQuery 3 upgrade guide if you use much jQuery elsewhere.

Not the answer you're looking for? Browse other questions tagged or ask your own question.