I am receiving an exception when attempting to connect to a hub from a console application. The error thrown is "Unexpected character encountered while parsing value: <.". It is thrown when I call
connection.Start().Wait()
Initially I had it all working in a test project and could send messages from the console to the clients. I then tried to port it to an existing MVC 3 web app and that is when the error started to occur.
Both the test web application and the existing application are hosted in IIS and have the same set up. If I try to connect to the test application everything still works ok, switching just the hub url to another port (for the exisitng app) and the connect
will fail.
I have ran fiddler and it would seem that the test web app is using server sent events and the exisitng project (one that doesn't work) is using long polling.
Javascript clients in the exisitng application are working fine and I can send messages to clients from different browsers, but the console application refuses to connect.
Does anyone have any idea what could be causing the connect to fail.
That message normally suggest that the url you're connecting to is incorrect or it could be that there was some sorta of error that occured when starting the connection. The reason you see "Unexpected character encountered while parsing value: <."
is because we expect a JSON response and HTML is being returned instead.
To see the error, you can do this:
Console.Error.WriteLine("========ERROR==========");
using (var error = ex.GetError())
{
Console.Error.WriteLine(error);
}
Console.Error.WriteLine("=======================");
Or you can use fiddler with Streaming mode on (click the Stream button) and look at the response from negotiate and view the html error page.
I got to the bottom of it this morning, I had to change my url in the console to my machine name from localhost so that I could see the negotiate response in Fiddler. Turns out I was getting an error from our internal SingleSignOn solution, adding a auth
cookie to the collection fixed the problem and the connection worked fine.
Thanks for the help.
Marked as answer by kalekylssen on Mar 25, 2013 12:04 PM
kalekylssen
0 Points
2 Posts
Unexpected character Connecting to Hub
Feb 09, 2013 01:15 PM|LINK
Hi,
I am receiving an exception when attempting to connect to a hub from a console application. The error thrown is "Unexpected character encountered while parsing value: <.". It is thrown when I call
Initially I had it all working in a test project and could send messages from the console to the clients. I then tried to port it to an existing MVC 3 web app and that is when the error started to occur.
Both the test web application and the existing application are hosted in IIS and have the same set up. If I try to connect to the test application everything still works ok, switching just the hub url to another port (for the exisitng app) and the connect will fail.
I have ran fiddler and it would seem that the test web app is using server sent events and the exisitng project (one that doesn't work) is using long polling.
Javascript clients in the exisitng application are working fine and I can send messages to clients from different browsers, but the console application refuses to connect.
Does anyone have any idea what could be causing the connect to fail.
davidfowl
Contributor
2699 Points
611 Posts
Microsoft
Re: Unexpected character Connecting to Hub
Feb 09, 2013 06:48 PM|LINK
That message normally suggest that the url you're connecting to is incorrect or it could be that there was some sorta of error that occured when starting the connection. The reason you see "Unexpected character encountered while parsing value: <." is because we expect a JSON response and HTML is being returned instead.
To see the error, you can do this:
Console.Error.WriteLine("========ERROR=========="); using (var error = ex.GetError()) { Console.Error.WriteLine(error); } Console.Error.WriteLine("=======================");Or you can use fiddler with Streaming mode on (click the Stream button) and look at the response from negotiate and view the html error page.
Senior SDE, ASP.NET Team, Microsoft
kalekylssen
0 Points
2 Posts
Re: Unexpected character Connecting to Hub
Feb 11, 2013 07:54 AM|LINK
Hi David,
Thanks for the reply.
I got to the bottom of it this morning, I had to change my url in the console to my machine name from localhost so that I could see the negotiate response in Fiddler. Turns out I was getting an error from our internal SingleSignOn solution, adding a auth cookie to the collection fixed the problem and the connection worked fine.
Thanks for the help.