Question

Using SignalR (v2.0.2) I'm getting this exception:

Value cannot be null.
Parameter name: o
   at Newtonsoft.Json.Utilities.ValidationUtils.ArgumentNotNull(Object value, String parameterName)
   at Newtonsoft.Json.Linq.JToken.FromObjectInternal(Object o, JsonSerializer jsonSerializer)
   at Newtonsoft.Json.Linq.JToken.FromObject(Object o, JsonSerializer jsonSerializer)
   at Microsoft.AspNet.SignalR.Client.Hubs.HubProxy.Invoke[T](String method, Object[] args)

I'm calling the HubProxy with reflection, and I am passing in some null arguments that are triggering this error (aka, some items in the Object[] args are null). However, passing null for an argument to a method is a perfectly legitimate thing to do. Is this a bug in SignalR in that it is trying to serialize null parameters or is it a bug in Json.NET (v6.0.1) in that it shouldn't attempt to serialize a null object?

Was it helpful?

Solution

Turns out this is a known bug in SignalR that has been fixed and will be included in the upcoming 2.2.1 release. See their ticket here.

OTHER TIPS

You can try to override SignalR hubs invocation method, for example: customize Microsoft.AspNet.SignalR.AuthorizeAttribute like this:

public override bool AuthorizeHubMethodInvocation(IHubIncomingInvokerContext hubIncomingInvokerContext, bool appliesToMethod)
{

}

Then before invoke, you can check your request and make some processing if needed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top