3

I am using a WinRT client. I receive this exception when I try to send a message.

Unexpected character encountered while parsing value: <.

The problem occurs when you send an object to the hub, and the object is not defined on the hub. The object is a Bindable object (ViewModel). I don't want to include all the property notify change stuff on the web project.

Client Code

return Proxy.Invoke("PlayerUpdate", sessionData);

Try one was to have the hub accept an 'object' parameter

public async Task PlayerUpdate(string group, object sessionData)
{
 await Clients[group].PlayerUpdate(sessionData);
}

Try two was to have the hub accept an (json) 'string' parameter

public async Task PlayerUpdate(string group, string sessionData)
{
 await Clients[group].PlayerUpdate(sessionData);
}

Try three was to pre-serialize the object client side

var str = JsonConvert.SerializeObject(refresh);
return Proxy.Invoke("PlayerUpdate", str);

Nothing is working. Plan 4 is to define some data transfer objects in a shared libarary to send. I really dont want to do that as It will about double my code.

nVentimiglia
  • 1,888
  • 4
  • 21
  • 37

3 Answers3

3

Solved.

My repo project was fine, so I concluded that something else was the matter.

After some experimentation I discovered the real problem was that I had incorrect parameters in my HUB method. Simply put, I was sending 2 parameters when my hub methods only accepted 1.

Thanks for the interest, sorry for the confusion. Perhaps a better exception message is in order?

nVentimiglia
  • 1,888
  • 4
  • 21
  • 37
0

This seems like an internal error with SignalR and I don't think anyone's going to be able to help you with this on StackOverflow. You should file an issue with the SignalR GitHub project.

Drew Marsh
  • 33,111
  • 3
  • 82
  • 100
0

My client was receiving this exception only when the site URL contained a trailing Default.aspx. The following cleaned up the HubConnection URL parameter:

string serverUri = new Uri(HtmlPage.Document.DocumentUri, ".").ToString();
HubConnection connection = new HubConnection(serverUri, true);
JDawg
  • 8,560
  • 4
  • 25
  • 29