Search code examples
azureservicebusmasstransit

MassTransit publish call hangs


I've been working on setting up a producer to load messages in Azure Service Bus using MassTransit. The code sits in our .net core web api. My method to send is pretty simple and looks like this.

public class ServiceBusProxy : IMessageProxy
{
    private readonly ILoggerManager _logger;
    private readonly IPublishEndpoint _endpoint;

    public ServiceBusProxy(ILoggerManager logger, IPublishEndpoint publishEndpoint)
    {
        _logger = logger;
        _endpoint = publishEndpoint;
    }

    public async Task QueueMessage(int userId, Message message)
    {
        await _endpoint.Publish(message);
    }
}

This code currently hangs on publish and doesn't return. I updated the calling code to use async and await as well. Configuration is pretty simple as well.

services.AddMassTransit(x =>
        {
            x.UsingAzureServiceBus((busContext, busConfig) =>
            {
                busConfig.Host("our connection string");
                busConfig.ConfigureEndpoints(busContext);
            });
        });

Is there something obvious that could be causing deadlock?


Solution

  • Feels very silly but added one config setting and now it works fine. The host call has some config where I set TransportType to ServiceBusTransportType.AmqpWebSockets.

    busConfig.Host("connection string", hostConfig =>
                    {
                        hostConfig.TransportType = ServiceBusTransportType.AmqpWebSockets;
                    });