Caio Pontalti
Caio Pontalti

Reputation: 1

System.TimeoutException: 'The requested operation on PersistentChannel has timed out with EasyNetQ

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;
}

Upvotes: 0

Views: 1053

Answers (2)

Caio Pontalti
Caio Pontalti

Reputation: 1

Problem solved by inserting port 5672 on the firewall.

Upvotes: 0

Wiebe Tijsma
Wiebe Tijsma

Reputation: 10265

  • 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.

Upvotes: 1

Related Questions