UseNServiceBus on .Net7 SQS

I am setting up my NServiceBus client to use Sqs like this:

private static void NServiceBusBuilder()
var builder = WebApplication.CreateBuilder();

    builder.Host.UseNServiceBus(context =>
        var endpointConfiguration = new EndpointConfiguration("samples_send_test_queue");
        var transport = new SqsTransport(
            new AmazonSQSClient(new AmazonSQSConfig()),
            new AmazonSimpleNotificationServiceClient());
        var routing = endpointConfiguration.UseTransport(transport);
        routing.RouteToEndpoint(typeof(RequestMessage), "samples_receive_test_queue");

        return endpointConfiguration;

When I try to use Endpoint.Start(endpointconfiguration) right after EnableInstallers the web api fails with an error. Here is the start code line Endpoint.Start(endpointConfiguration).ConfigureAwait(false);

Error Message:
Web server failed to listen on port 8085

How do I debug this? Am I setting up everything correctly? Is it possible I do not have something correctly configured to connect to AWS? If so shouldn’t I get an error and not just crash? Thanks.

Good day @JackInTheBoxBen. Welcome to the Particular discussion group.

It looks like the error is unrelated to NServiceBus. We don’t set up a web server/listener, nor does the transport or the AWS SDK client, as far as I can tell.

Is this happening on your local machine or in AWS after having deployed the project?

If this is happening on your machine and considering that you’re setting up a WebApllication, look in the launchSettings.json file in the Properties folder of the Visual Studio project and verify if the assigned port is the same as mentioned in the error. If that’s the case, the port might be already in use by something else on the machine.

This is happening on my local PC. Here are my launch settings.
“http”: {
“commandName”: “Project”,
“launchBrowser”: true,
“launchUrl”: “swagger”,
“environmentVariables”: {
“AWS_PROFILE”: “development”,
“AWS_REGION”: “us-west-2”
“dotnetRunMessages”: true,
“applicationUrl”: “http://localhost:8085
Yes the port in error is the same however I have tried other ports too. Lastly the problem only occurs when this line of code is included:
Somehow I don’t think I am connecting correctly. Does my code look correct? Thanks.

Everything looks legit to me.

The only missing bits from the launch settings are the export AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY variables to connect to SQS.