.net-coremasstransit

Cannot get MassTransit response after successfully initiating request


I am implementing request/response with MassTransit and Amazon MQ. The (.NET 6 WebApi) host is configured like:

services
    .AddMassTransit(x =>
    {
        x.AddConsumer<ConfigurationConsumer>();
        x.UsingRabbitMq((context, cfg) =>
        {
            cfg.Host(new Uri($"amqps://{rabbitMqSettings.Host}:{rabbitMqSettings.Port}/{Uri.EscapeDataString("/vhostname")}"), h =>
            {
                h.Username(rabbitMqSettings.Username);
                h.Password(rabbitMqSettings.Password);
            });
            cfg.ConfigureEndpoints(context);
        });
        x.AddRequestClient<IConfigurationCommand>();
    })
    .AddMassTransitHostedService();

The client uses the same configuration without x.AddConsumer() and cfg.ConfigureEndpoints(context).

The problem is: calling GetResponse on the client will successfully execute the consumer on the host which seems to respond as intended, but the client never gets a result and times out.

On the other hand, when I am using a web api controller on the same host to initiate GetResponse, everything works as expected.


Solution

  • Ensure that the message types between the host and the client applications are the same.

    ALSO, make sure the bus is started on the client using the hosted service or otherwise.