question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot develop locally using Localstack

See original GitHub issue

Is this a bug report?

Yes.

Can you also reproduce the problem with the latest version?

Yes, I can. Here is a link to a sample repo. https://github.com/rabberbock/MassTransitLocalstack/

Environment

  1. Operating system: Windows 10
  2. Visual Studio version: Visual Studio 2019
  3. Dotnet version: .Net Core 3.0 preview 5

Steps to Reproduce

  1. Download the Sample project from https://github.com/rabberbock/MassTransitLocalstack.
  2. Make sure you have .Net Core 3 preview 5 installed
  3. Have localstack running on your computer. (I ran it via docker and added docker.localhost to the hosts file). I am using the sqs transport. I tried it with go-aws as well and got the same error.
  4. Run the application, and notice the error when trying to execute the handler.

Expected Behavior

It should execute the handler with no errors.

Actual Behavior

Currently message deserialization is broken using localstack to emulate sqs and sns. Running this with a real AWS sqs and sns actually works.

 R-FAULT amazonsqs://us-east-1/my_queue 7db85235-948f-4060-b37f-9568e3e51de3 Value cannot be null.
      Parameter name: source
System.Runtime.Serialization.SerializationException: An exception occurred while deserializing the message envelope ---> System.ArgumentNullException: Value cannot be null.
Parameter name: source
   at System.Linq.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument)
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at MassTransit.Serialization.JsonConsumeContext..ctor(JsonSerializer deserializer, IObjectTypeDeserializer objectTypeDeserializer, ReceiveContext receiveContext, MessageEnvelope envelope)
   at MassTransit.Serialization.JsonMessageDeserializer.MassTransit.IMessageDeserializer.Deserialize(ReceiveContext receiveContext)
   --- End of inner exception stack trace ---
   at MassTransit.Serialization.JsonMessageDeserializer.MassTransit.IMessageDeserializer.Deserialize(ReceiveContext receiveContext)
   at MassTransit.Serialization.SupportedMessageDeserializers.Deserialize(ReceiveContext receiveContext)
   at MassTransit.Pipeline.Filters.DeserializeFilter.Send(ReceiveContext context, IPipe`1 next)
   at GreenPipes.Filters.RescueFilter`2.GreenPipes.IFilter<TContext>.Send(TContext context, IPipe`1 next)
dbug: MassTransit.Messages[0]
      SEND amazonsqs://us-east-1/MassTransit-ReceiveFault 47360000-5d56-0015-5d31-08d6f2863ce7 MassTransit.ReceiveFault
dbug: MassTransit.Messages[0]
      SEND amazonsqs://us-east-1/MassTransit-ReceiveFault 47360000-5d56-0015-3386-08d6f2863ceb MassTransit.ReceiveFault

Reproducible Demo

https://github.com/rabberbock/MassTransitLocalstack.

Thanks for all your help!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:24 (19 by maintainers)

github_iconTop GitHub Comments

3reactions
phatboygcommented, Mar 23, 2021

You can check the options used in the unit tests via docker-compose for localstack that I use to test MassTransit.

The test harness settings shown here are the key to connecting locally.

1reaction
diegosaswcommented, Mar 23, 2021

Thanks so much. Following with my example, this works fine to connect to localstack as per previous message.

var region = "localhost:4566";
var accessKey = "test";
var secretKey = "test";
var busControl = Bus.Factory.CreateUsingAmazonSqs(c =>
{
    var hostAddress = new Uri($"amazonsqs://{region}")
    var hostConfigurator = new AmazonSqsHostConfigurator(hostAddress);
    hostConfigurator.AccessKey(accessKey);
    hostConfigurator.SecretKey(secretKey);
    hostConfigurator.Config(new AmazonSimpleNotificationServiceConfig {ServiceURL = $"http://{region}"});
    hostConfigurator.Config(new AmazonSQSConfig {ServiceURL = $"http://{region}"});
    c.Host(hostConfigurator.Settings);
});

Amazing help, as always!

PS: Careful with localstack versions. Some of them don’t work. See https://stackoverflow.com/questions/66767011/localstack-with-masstransit-not-getting-messages

Read more comments on GitHub >

github_iconTop Results From Across the Web

Development Environment Setup
Setting up Development Environment​​ To make contributions to LocalStack, you need to be able to run LocalStack in host mode from your IDE,...
Read more >
localstack trying to connect to localhost:4566 when we ...
My team is trying to get a local setup for our project. We are running the same docker-compose file with image localstack/localstack:0.8.10 ...
Read more >
Local Development with AWS on LocalStack
LocalStack is a Python application designed to run as an HTTP request processor while listening on specific ports. Our usage of LocalStack is ......
Read more >
Develop Your Cloud App Locally with the LocalStack ...
Learn how to use the LocalStack Docker Extension to emulate a cloud service locally with Docker Desktop.
Read more >
How to fake AWS locally with LocalStack
Once the AWS CLI is installed, run aws configure to create some credentials. Even though we're talking to our "fake" local service, we...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found