GetIpAddress inside a .NET WCF IErrorHandler hook throws an exception
nlewis
Posted on
Feb 10 2015
We have a global WCF error handler setup to log errors to Log4Net right now. We tried to add Raygun to the same hook and new RaygunClient().Send(error) ends up causing its own exception which either makes the error handler re-entrant or ends up crashing IIS.
Since WCF can be a bit tricky to setup, I've put together a VS2013 test project to duplicate the problem. It is a simple WCF service that exposes a single method called ThrowException via REST/JSON.
You can grab it here: https://drive.google.com/file/d/0BxhNzfsBi-PGQnZSYmMtcG00OWs/view?usp=sharing
At the heart of the slew of errors that are thrown is a NullReferenceException in this stack trace:
System.Web.dll!System.Web.HttpServerVarsCollection.Get(string name = {unknown}) C#
Mindscape.Raygun4Net.dll!Mindscape.Raygun4Net.Builders.RaygunRequestMessageBuilder.GetIpAddress(System.Web.HttpRequest request = {unknown}) C#
Mindscape.Raygun4Net.dll!Mindscape.Raygun4Net.Builders.RaygunRequestMessageBuilder.Build(System.Web.HttpRequest request = {unknown}, Mindscape.Raygun4Net.RaygunRequestMessageOptions options = {unknown}) C#
Mindscape.Raygun4Net.dll!Mindscape.Raygun4Net.RaygunClient.BuildRequestMessage() C#
Mindscape.Raygun4Net.dll!Mindscape.Raygun4Net.RaygunClient.Send(System.Exception exception = {unknown}, System.Collections.Generic.IList<string> tags = {unknown}, System.Collections.IDictionary userCustomData = {unknown}, Mindscape.Raygun4Net.Messages.RaygunIdentifierMessage userInfo = {unknown}) C#
Mindscape.Raygun4Net.dll!Mindscape.Raygun4Net.RaygunClient.Send(System.Exception exception = {unknown}) C#
> WCFRaygunTest.dll!WCFRaygunTest.RaygunWcfErrorHandler.HandleError(System.Exception error = {unknown}) C#
We prefer to use this method to capture WCF errors because it can catch an entire class of errors deep in WCF such as serialization errors which occur after the WCF service method returns.
Jason Fauchelle
Raygun
Posted on
Feb 13 2015
Hello
Thanks for reporting this and providing a repro project. This issue has been resolved in the latest version of Raygun4Net (v4.2.1) which you can update through NuGet.
-Jason Fauchelle