ajax - SIGNALR: $.connection.hub.start() results in "Error parsing negotiate response." -
i had basic signalr functionality implemented , working in mvc5/angularjs application recently, after shelfing , unshelfing changes getting error when connection negotiated in $.connection.hub.start().
i've stripped down code basics, still error. poking around in jquery.signalr-2.2.0.js negotiate request made, found result returned ajax request http://localhost:44379/signalr/negotiate?clientprotocol=1.5&connectiondata=[] returning html of page instead of json data!
connection._.negotiaterequest = /* on line 659 */ signalr.transports._logic.ajax(connection, { url: url, // http://localhost:44379/signalr/negotiate?clientprotocol=1.5&connectiondata=%5b%5d error: function (error, statustext) { // irrelevant code removed. }, success: function (result) { // here @ least... var res, keepalivedata, protocolerror, transports = [], supportedtransports = []; try { res = connection._parseresponse(result); // fails because result contains html. } catch (error) { // error.message "unexpected token <" onfailed(signalr._.error(resources.errorparsingnegotiateresponse, error), connection); return; } here javascript establishing hub/connection:
$(function () { var hub = $.connection.testhub; if (hub) console.log("signalr hub initialized."); $.connection.hub.start().done(function () { console.log("signalr connection established."); }).fail(function (err) { console.log("error starting signalr connection: " + err); // ends here. }); }); and script references (i have signalr code in separate js file named messaging.js):
<script src="~/assets/js/signalr/jquery.signalr-2.2.0.js"></script> <script src="~/scripts/messaging/messaging.js"></script> <script src="~/signalr/hubs"></script> i don't understand why ajax response signalr/negotiate returning html instead of json. i've stripped down server side hub code empty class [allowanonymous] ensure nothing in there causing problem. have app.mapsignalr() call in startup.cs in place. first thought, since occurred after shelfing , unshelfing, didn't make shelf , lost, can't seem find missing...
anyone have ideas?
i found problem while playing rules in web.config. previously, had rule signalr:
<add input="{request_uri}" matchtype="pattern" pattern="/signalr/hubs" negate="true" /> changing pattern allowed communication /signalr/negotiate, think:
<add input="{request_uri}" matchtype="pattern" pattern="^/(signalr)" negate="true"/> ...i have no idea how worked before.
Comments
Post a Comment