Hey guys I have a problem which I need a little help with. I have a SignalR web project which I communicate with through a console application. When I run my SignalR Web application locally it works fine without any issues but when I deploy it to IIS and try create the hub proxy I get the error below, I have been pulling my hair out all day and I can't find a solution. Any help is very much apreciated.
Error:
"Unexpected character encountered while parsing value: <. Path '', line 3, position 1."}
Console application:
var connection = new HubConnection(txtSignalRWebsite.Text);
var myHub = connection.CreateHubProxy("dbHub");
connection.Start().ContinueWith(task =>
{
if (task.IsFaulted)
{
Console.WriteLine("Error" + task.Exception.ToString());
}
else
{
myHub.Invoke("DisplayHello");
}
}).Wait();
Stack Trace
(Inner Exception #0) Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: <. Path '', line 3, position 1.
at Newtonsoft.Json.JsonTextReader.ParseValue()
at Newtonsoft.Json.JsonTextReader.ReadInternal()
at Newtonsoft.Json.JsonTextReader.Read()
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ReadForType(JsonReader reader, JsonContract contract, Boolean hasConverter)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value)
at Microsoft.AspNet.SignalR.Client.Transports.TransportHelper.<GetNegotiationResponse>b__0(IResponse response)
at Microsoft.AspNet.SignalR.TaskAsyncHelper.<>c__DisplayClass23`2.<Then>b__21(Task`1 t)
at Microsoft.AspNet.SignalR.TaskAsyncHelper.TaskRunners`2.<>c__DisplayClass48.<RunTask>b__47(Task`1 t)<---
Generated Hubs Js file
(function ($, window) {
"use strict";
if (typeof ($.signalR) !== "function") {
throw new Error("SignalR: SignalR is not loaded. Please ensure jquery.signalR-x.js is referenced before ~/signalr/hubs.");
}
var signalR = $.signalR;
function makeProxyCallback(hub, callback) {
return function () {
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)) {
continue;
}
if (shouldSubscribe) {
subscriptionMethod = hub.on;
}
else {
subscriptionMethod = hub.off;
}
for (memberKey in hub.client) {
if (hub.client.hasOwnProperty(memberKey)) {
memberValue = hub.client[memberKey];
if (!$.isFunction(memberValue)) {
continue;
}
subscriptionMethod.call(hub, memberKey, makeProxyCallback(hub, memberValue));
}
}
}
}
}
$.hubConnection.prototype.createHubProxies = function () {
var proxies = {};
this.starting(function () {
registerHubProxies(proxies, true);
this._registerSubscribedHubs();
}).disconnected(function () {
registerHubProxies(proxies, false);
});
proxies.clientNotificationHub = this.createHubProxy('clientNotificationHub');
proxies.clientNotificationHub.client = { };
proxies.clientNotificationHub.server = {
checkForPasswordExpiry: function (iUserId, iConnectionId) {
return proxies.clientNotificationHub.invoke.apply(proxies.clientNotificationHub, $.merge(["CheckForPasswordExpiry"], $.makeArray(arguments)));
}
};
proxies.dbHub = this.createHubProxy('dbHub');
proxies.dbHub.client = { };
proxies.dbHub.server = {
displayHello: function () {
return proxies.dbHub.invoke.apply(proxies.dbHub, $.merge(["DisplayHello"], $.makeArray(arguments)));
},
processMessage: function (_lstNotificationJSON, sUserName) {
return proxies.dbHub.invoke.apply(proxies.dbHub, $.merge(["ProcessMessage"], $.makeArray(arguments)));
},
setConnection: function (iUserId) {
return proxies.dbHub.invoke.apply(proxies.dbHub, $.merge(["SetConnection"], $.makeArray(arguments)));
},
updateClientNotification: function (iClientNotificationId, eEventType, csNotification, iUserId) {
return proxies.dbHub.invoke.apply(proxies.dbHub, $.merge(["UpdateClientNotification"], $.makeArray(arguments)));
},
updateClientNotificationProcessed: function (iClientNotificationId) {
return proxies.dbHub.invoke.apply(proxies.dbHub, $.merge(["UpdateClientNotificationProcessed"], $.makeArray(arguments)));
}
};
return proxies;
};
signalR.hub = $.hubConnection("/i-conX_10_2_SignalR/signalr", { useDefaultPath: false });
$.extend(signalR, signalR.hub.createHubProxies());
}(window.jQuery, window));