NService Bus. NETCore and Proxy PROBLEM




I’m trying to build a sample app with NServiceBus using .Net core 2.1. But when I’m trying to start an endpoint for example (Endpoint.Start(…)) I got this problem:
Error Code: 407 Proxy Authentication Required. Forefront TMG requires authorization to fulfill the request. Access to the Web Proxy filter is denied. (12209)

It is true that we are using a proxy system in our company but I’am able to run the same example in .NET Framework By adding in the app.config this configuration:


We cannot for sure have this part in .NET CORE project and we are planning to Use .NET CORE so is There any support for this scenario?

(Ramon Smits) #2

In .net core you would normally prepare the HttpClient and pass that on for usage.

var handler = new HttpClientHandler();
handler.DefaultProxyCredentials = CredentialCache.DefaultCredentials;
var client = new HttpClient(handler);

Sometimes code isn’t using the HttpClient in that case you would need the following:

var proxy = new WebProxy("http://webproxy:3128");
proxy.Credentials = CredentialCache.DefaultCredentials;
WebRequest.DefaultWebProxy = proxy;

Which sample is it that you are trying to run that requires outgoing access? Which transport and persistence is being used?

– Ramon



I’m using this transport NServiceBus.Transport.AzureServiceBus (Version 1.0.0-alpha0172)
and I’m trying to use this sample https://docs.particular.net/samples/azure-service-bus-netstandard/native-integration/

(Daniel Marbach) #4

Hi Sam,

This seems to be an issue with .NET Core and not much we can do, see

and to quote a user from these conversations

This also includes the Azure WebJobs SDK. I was never able to get it running behind our evil company proxy ( System.Net.Http.UseSocketsHttpHandler does not work). For several years .Net Core is an endless source of frustration. :-1:


It might be best to make some noise on those issues I think.


(Daniel Marbach) #5

Hi Sam,

I have not tested this but maybe it is possible to use the websocket communciation with ASB and configure the proxy there?





Hi Daniel,

Thank you for your reply. Even while using “tansport.UseWebSockets()” I’m still having the same problem. I’m trying to find some example to use transport.CustomTokenProvider properly maybe this will solve my problem.

Can we have a call maybe?
Thanks :slight_smile:

(Sean Feldman) #7

The transport is creating topology (entities) as well as verifying what permissions it has on the namespace. That’s done using native ASB client’s ManagementClient, which in turn using HTTPS to communicate to the broker. Switching to WebSockets won’t help if the native client doesn’t respect proxy settings.

Could you try running with Full Framework to see if the native client respect those settings?

Also, regarding CustomTokenProvider - that’s not something you’d do for the transport, but for authentication. Native client support SAS Token provider and AAD provider. This property would be needed If you need to create your own token provider.