SignalR 2.0.0 / JsonSerializerSettings: MaxDepth reader out of 20 exceeded

I get the following error when sending a message to the server using SignalR 2.0.0 :

Signal R: MaxDepth of 20 reader exceeded.

I use Unity for DI and tried to register an instance of JsonSerializer:

GlobalHost.DependencyResolver.Register(
    typeof (JsonSerializer),
    () => JsonSerializer.Create(
         new JsonSerializerSettings
         {
             ContractResolver = new DefaultContractResolver(),
             MaxDepth = int.MaxValue
         }));

I have a case:

object IDependencyResolver.GetService(Type serviceType)
{
    var result = _container.IsRegistered(serviceType) ? _container.Resolve(serviceType) : base.GetService(serviceType);

    if (result != null && result.GetType().FullName.Equals("Newtonsoft.Json.JsonSerializer", StringComparison.OrdinalIgnoreCase))
    {
        ((Newtonsoft.Json.JsonSerializer) result).MaxDepth = int.MaxValue;
    }

    return result;
}

The error just does not go away. As if SignalR was just using another instance of JsonSerializer.

+3
source share
1 answer

I registered the following issue on GitHub:

https://github.com/SignalR/SignalR/issues/2911

This seems to be a known issue, so our solution was to replace the SignalR bit, which pushes our messages to our server using POST Web-Api Ajax.

+1
source

All Articles