Click here to Skip to main content
15,883,901 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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:
C#
var connection = new HubConnection(txtSignalRWebsite.Text);
//Make proxy to hub based on hub name on server
var myHub = connection.CreateHubProxy("dbHub");

//Start connection
connection.Start().ContinueWith(task =>
{
    if (task.IsFaulted)
    {
        Console.WriteLine("Error" + task.Exception.ToString());
    }
    else
    {
        myHub.Invoke("DisplayHello");
    }
}).Wait();


Stack Trace
C#
(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
JavaScript
/*!
 * ASP.NET SignalR JavaScript Library v1.1.0
 * http://signalr.net/
 *
 * Copyright Microsoft Open Technologies, Inc. All rights reserved.
 * Licensed under the 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 is not loaded. Please ensure jquery.signalR-x.js is referenced before ~/signalr/hubs.");
    }

    var signalR = $.signalR;

    function makeProxyCallback(hub, callback) {
        return function () {
            // Call the client hub method
            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)) {
                    // Not a client hub
                    continue;
                }

                if (shouldSubscribe) {
                    // We want to subscribe to the hub events
                    subscriptionMethod = hub.on;
                }
                else {
                    // We want to unsubscribe from the hub events
                    subscriptionMethod = hub.off;
                }

                // Loop through all members on the hub and find client hub functions to subscribe/unsubscribe
                for (memberKey in hub.client) {
                    if (hub.client.hasOwnProperty(memberKey)) {
                        memberValue = hub.client[memberKey];

                        if (!$.isFunction(memberValue)) {
                            // Not a client hub function
                            continue;
                        }

                        subscriptionMethod.call(hub, memberKey, makeProxyCallback(hub, memberValue));
                    }
                }
            }
        }
    }

    $.hubConnection.prototype.createHubProxies = function () {
        var proxies = {};
        this.starting(function () {
            // Register the hub proxies as subscribed
            // (instance, shouldSubscribe)
            registerHubProxies(proxies, true);

            this._registerSubscribedHubs();
        }).disconnected(function () {
            // Unsubscribe all hub proxies when we "disconnect".  This is to ensure that we do not re-add functional call backs.
            // (instance, shouldSubscribe)
            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));
Posted
Updated 7-Mar-14 10:29am
v4
Comments
ZurdoDev 7-Mar-14 10:34am    
Sounds like a config file syntax issue somewhere.
frostcox 7-Mar-14 10:37am    
Could you be more specific?
idenizeni 7-Mar-14 14:32pm    
Check your config file to see if you have a < character in one of the values. If so you probably want to encode it as config files are XML and < is a special character in XML.
frostcox 7-Mar-14 15:18pm    
Hey there's def no extra "<" in the config file. The application runs like a treat locally its only after deployment I get the issue??

1 solution

Ok I finally found the solution to this. In IIS there is a setting Deny Anonymous users, by default this is set to true. So after I successfully authenticated the console application it worked like a treat.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900