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.
source
share