javascript - SignalR upgrade 0.5.3 to 1.0.x issues -



javascript - SignalR upgrade 0.5.3 to 1.0.x issues -

i have/am upgraded/upgrading signalr 0.5.3 1.0.x rc2 , having problems creating connection.

the issue hitting exception:

typeerror: res null

connection.apprelativeurl = res.url;

my script create connection has been stripped right default demo code:

var connection = $.connection('/signalr'); connection.start(function () { console.log("connection started!"); });

still error. when step jquery.signalr.js file, , nail connection code:

var url = connection.url + "/negotiate"; connection.log("negotiating '" + url + "'."); $.ajax({ url: url, global: false, cache: false, type: "get", data: {}, datatype: connection.ajaxdatatype, error: function (error) { $(connection).triggerhandler(events.onerror, [error.responsetext]); deferred.reject("signalr: error during negotiation request: " + error.responsetext); // stop connection if negotiate failed connection.stop(); }, success: function (res) { var keepalivedata = connection.keepalivedata; connection.apprelativeurl = res.url;

i'm getting lastly line , res parameter null bombing out connection attempt. have updated signalr dependencies, changed hub client side calls utilize additional client/server properties in hubs.

my /signalr/hubs js script beingness created , has right methods mapping server side hub methods expect available. js file follows:

/*! * asp.net signalr javascript library v1.0.0 * http://signalr.net/ * * copyright microsoft open technologies, inc. rights reserved. * licensed under apache 2.0 * https://github.com/signalr/signalr/blob/master/license.md * */ /// <reference path="..\..\signalr.client.js\scripts\jquery-1.6.4.js" /> /// <reference path="jquery.signalr.js" /> (function ($, window) { /// <param name="$" type="jquery" /> "use strict"; if (typeof ($.signalr) !== "function") { throw new error("signalr: signalr not loaded. please ensure jquery.signalr-x.js referenced before ~/signalr/hubs."); } var signalr = $.signalr; function makeproxycallback(hub, callback) { homecoming function () { // phone call client hub method callback.apply(hub, $.makearray(arguments)); }; } function registerhubproxies(instance, shouldsubscribe) { var key, hub, memberkey, membervalue, subscriptionmethod; (key in instance) { if (instance.hasownproperty(key)) { hub = instance[key]; if (!(hub.hubname)) { // not client hub continue; } if (shouldsubscribe) { // want subscribe hub events subscriptionmethod = hub.on; } else { // want unsubscribe hub events subscriptionmethod = hub.off; } // loop through members on hub , find client hub functions subscribe/unsubscribe (memberkey in hub.client) { if (hub.client.hasownproperty(memberkey)) { membervalue = hub.client[memberkey]; if (!$.isfunction(membervalue)) { // not client hub function continue; } subscriptionmethod.call(hub, memberkey, makeproxycallback(hub, membervalue)); } } } } } $.hubconnection.prototype.createhubproxies = function () { var proxies = {}; this.starting(function () { // register hub proxies subscribed // (instance, shouldsubscribe) registerhubproxies(proxies, true); this._registersubscribedhubs(); }).disconnected(function () { // unsubscribe hub proxies when "disconnect". ensure not re-add functional phone call backs. // (instance, shouldsubscribe) registerhubproxies(proxies, false); }); proxies.chathub = this.createhubproxy('chathub'); proxies.chathub.client = { }; proxies.chathub.server = { exitchat: function (chatid) { /// <summary>calls exitchat method on server-side chathub hub.&#10;returns jquery.deferred() promise.</summary> /// <param name=\"chatid\" type=\"string\">server side type system.string</param> homecoming proxies.chathub.invoke.apply(proxies.chathub, $.merge(["exitchat"], $.makearray(arguments))); }, getchat: function (chatid) { /// <summary>calls getchat method on server-side chathub hub.&#10;returns jquery.deferred() promise.</summary> /// <param name=\"chatid\" type=\"string\">server side type system.string</param> homecoming proxies.chathub.invoke.apply(proxies.chathub, $.merge(["getchat"], $.makearray(arguments))); }, joinchat: function (chatid, inviteeuserids, groupid) { /// <summary>calls joinchat method on server-side chathub hub.&#10;returns jquery.deferred() promise.</summary> /// <param name=\"chatid\" type=\"string\">server side type system.string</param> /// <param name=\"inviteeuserids\" type=\"object\">server side type system.string[]</param> /// <param name=\"groupid\" type=\"string\">server side type system.string</param> homecoming proxies.chathub.invoke.apply(proxies.chathub, $.merge(["joinchat"], $.makearray(arguments))); }, sendchatmessage: function (chatid, messageid, message) { /// <summary>calls sendchatmessage method on server-side chathub hub.&#10;returns jquery.deferred() promise.</summary> /// <param name=\"chatid\" type=\"string\">server side type system.string</param> /// <param name=\"messageid\" type=\"string\">server side type system.string</param> /// <param name=\"message\" type=\"string\">server side type system.string</param> homecoming proxies.chathub.invoke.apply(proxies.chathub, $.merge(["sendchatmessage"], $.makearray(arguments))); }, typing: function (chatid, istyping) { /// <summary>calls typing method on server-side chathub hub.&#10;returns jquery.deferred() promise.</summary> /// <param name=\"chatid\" type=\"string\">server side type system.string</param> /// <param name=\"istyping\" type=\"\">server side type system.boolean</param> homecoming proxies.chathub.invoke.apply(proxies.chathub, $.merge(["typing"], $.makearray(arguments))); } }; proxies.debughub = this.createhubproxy('debughub'); proxies.debughub.client = { }; proxies.debughub.server = { registerwithdebugger: function () { /// <summary>calls registerwithdebugger method on server-side debughub hub.&#10;returns jquery.deferred() promise.</summary> homecoming proxies.debughub.invoke.apply(proxies.debughub, $.merge(["registerwithdebugger"], $.makearray(arguments))); } }; proxies.grouphub = this.createhubproxy('grouphub'); proxies.grouphub.client = { }; proxies.grouphub.server = { joingroup: function (userid, groupid) { /// <summary>calls joingroup method on server-side grouphub hub.&#10;returns jquery.deferred() promise.</summary> /// <param name=\"userid\" type=\"string\">server side type system.string</param> /// <param name=\"groupid\" type=\"string\">server side type system.string</param> homecoming proxies.grouphub.invoke.apply(proxies.grouphub, $.merge(["joingroup"], $.makearray(arguments))); }, joingroups: function (userid) { /// <summary>calls joingroups method on server-side grouphub hub.&#10;returns jquery.deferred() promise.</summary> /// <param name=\"userid\" type=\"string\">server side type system.string</param> homecoming proxies.grouphub.invoke.apply(proxies.grouphub, $.merge(["joingroups"], $.makearray(arguments))); }, leavegroup: function (userid, groupid) { /// <summary>calls leavegroup method on server-side grouphub hub.&#10;returns jquery.deferred() promise.</summary> /// <param name=\"userid\" type=\"string\">server side type system.string</param> /// <param name=\"groupid\" type=\"string\">server side type system.string</param> homecoming proxies.grouphub.invoke.apply(proxies.grouphub, $.merge(["leavegroup"], $.makearray(arguments))); } }; proxies.userhub = this.createhubproxy('userhub'); proxies.userhub.client = { }; proxies.userhub.server = { registeruserclient: function (userid) { /// <summary>calls registeruserclient method on server-side userhub hub.&#10;returns jquery.deferred() promise.</summary> /// <param name=\"userid\" type=\"string\">server side type system.string</param> homecoming proxies.userhub.invoke.apply(proxies.userhub, $.merge(["registeruserclient"], $.makearray(arguments))); }, updateuserclientstatus: function (userid, latestheartbeat, latestinteractivity) { /// <summary>calls updateuserclientstatus method on server-side userhub hub.&#10;returns jquery.deferred() promise.</summary> /// <param name=\"userid\" type=\"string\">server side type system.string</param> /// <param name=\"latestheartbeat\" type=\"object\">server side type system.datetime</param> /// <param name=\"latestinteractivity\" type=\"object\">server side type system.datetime</param> homecoming proxies.userhub.invoke.apply(proxies.userhub, $.merge(["updateuserclientstatus"], $.makearray(arguments))); } }; homecoming proxies; }; signalr.hub = $.hubconnection("/signalr", { usedefaultpath: false }); $.extend(signalr, signalr.hub.createhubproxies()); }(window.jquery, window));

any ideas?

turns out there nil wrong code above. migration signalr 0.5.3 1.0.x went without hitch. problem dev environment quite messed up.

there 1 massive gotcha in our case - using ravendb. there dependency both on different versions of newtonsoft json.

if you're in situation using both of these technologies together, careful passing json objects formatted in previous version of newtonsoftjson 1 other resultant json serialized objects not backward compatible.

you have map them manually when passing raven signalr js client.

javascript asp.net-mvc signalr

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -