0

I'm starting at RabbitMq and I'm having trouble starting my API. This error occurred: System.TimeoutException: 'The requested operation on PersistentChannel has timed out'.

I am using EasyNetQ.

RabbitMq is running in a Docker container that is configured as settings: http: 15672 and ampq: 56712. Click here to access Rabbitmq without any problems in the browser.

Below is the code (for now the hardcode) of the settings. Try to pass the username and password as well, but without success, according to the code.

protected override Task ExecuteAsync(CancellationToken stoppingToken)
{
    _bus = RabbitHutch.CreateBus("host=localhost:5672;username=guest;password=guest");

    _bus.RespondAsync<UsuarioRegistradoIntegrationEvent, ResponseMessage>(async request =>
        new ResponseMessage(await RegistrarCliente(request)));

    return Task.CompletedTask;
}

ou

protected override Task ExecuteAsync(CancellationToken stoppingToken)
{
    _bus = RabbitHutch.CreateBus("host=localhost:5672");

    _bus.RespondAsync<UsuarioRegistradoIntegrationEvent, ResponseMessage>(async request =>
        new ResponseMessage(await RegistrarCliente(request)));

    return Task.CompletedTask;
}

ou

protected override Task ExecuteAsync(CancellationToken stoppingToken)
{
    _bus = RabbitHutch.CreateBus("host=localhost");

    _bus.RespondAsync<UsuarioRegistradoIntegrationEvent, ResponseMessage>(async request =>
        new ResponseMessage(await RegistrarCliente(request)));

    return Task.CompletedTask;
}

2 Answers2

1
  • You mention a non-default port for AMQP in your description, please change 56712 to 5672 in your container (if applicable)
  • Make sure you only call RabbitHutch.CreateBus("host=localhost") once per application instance (share the instance).
  • Make sure you await all async calls:
    protected override async Task ExecuteAsync(CancellationToken stoppingToken)
    {
        _bus = RabbitHutch.CreateBus("host=localhost");
    
        await _bus.RespondAsync<UsuarioRegistradoIntegrationEvent, ResponseMessage>(async request =>
            new ResponseMessage(await RegistrarCliente(request)));
    }

We're missing the implementation of RegistrarCliente(request) which makes it difficult to spot any other problems.

Wiebe Tijsma
  • 10,173
  • 5
  • 52
  • 68
  • Hello, thanks for the reply! I changed it to port 5672 and the same persistent error. After many tests, I decided to add this port to the Windows firewall and it ended up working. I thought it was strange why I didn't see this solution in any question here at Stack or elsewhere. Anyway, thanks a lot for the help brother! – Caio Pontalti Jul 05 '20 at 16:05
0

Problem solved by inserting port 5672 on the firewall.