0

In a ASP.Net Core website I am using NLog with a StackifyTarget to log to Stackify Retrace. Our code is running behind a corporate HTTP proxy.

I have some custom code that returns a WebProxy. The WebProxy is then set on StackifyLib.Utils.HttpClient.CustomWebProxy, in the Configure method of the StartUp.cs.

When a log is written, it is written successfully to file, but not to the StackifyTarget.

When I investigate the network traffic using Fiddler, I can see that there are 407/Proxy AuthenticationRequired errors for outbound traffic to the Stackify servers.

Using the same StackifyTarget in a WinForms application, .Net Framework 4.7.2, it just works fine:

<system.net>
    <defaultProxy useDefaultCredentials="true" />
</system.net>

When I set a breakpoint on the Log.Info, I can see that the proxy information is still set on the StackifyLib. How can have StackifyLib work correctly with the proxy, in ASP.Net Core?

Michel van Engelen
  • 2,791
  • 2
  • 29
  • 45
  • 1
    Think you have to contact `support@stackify.com` and have them fix the existing issue: https://github.com/stackify/stackify-api-dotnet/issues/81 by using HttpClientHandler as recommended by Microsoft: https://github.com/dotnet/corefx/issues/28780#issuecomment-378322214 – Rolf Kristensen Feb 06 '19 at 19:38
  • 1
    The custom code that assigns proxy to `CustomWebProxy` could also try and assign this first `System.Net.WebRequest.DefaultWebProxy = webProxy;` (As the very first thing in the application, before Stackify-HttpClient is created). – Rolf Kristensen Feb 06 '19 at 19:46
  • 1
    @RolfKristensen: it worked! It seems that when the proxy is set after StackifyLib is initialized, it isn't picking up the settings anymore. If you add it as an answer, I'll vote for it! – Michel van Engelen Feb 11 '19 at 14:19

2 Answers2

1

The custom code that assigns proxy to CustomWebProxy could also try and assign this first:

System.Net.WebRequest.DefaultWebProxy = webProxy;

As the very first thing in the application, before Stackify-HttpClient is created.

Rolf Kristensen
  • 17,785
  • 1
  • 51
  • 70
0

Stackify has 2 docs that may help with this: https://docs.stackify.com/docs/troubleshoot-errors-and-logs-net-configurations https://docs.stackify.com/docs/http-proxies-configure

If either of these do not work you can submit a ticket to them to support@stackify.com

James Kenney
  • 147
  • 1