moleculerjs / moleculer-channels

Reliable messages for Moleculer services via external queue/channel/topic.
MIT License
72 stars 15 forks source link

amqp failed to reconnect #49

Closed me23 closed 1 year ago

me23 commented 1 year ago

Prerequisites

Please answer the following questions for yourself before submitting an issue.

Current Behavior

I start a service with amqp-transport (rabbitmq) and moleculer-channels listen to a given topic. If the amqp-server connection breaks than, molceuler-channels won't reconnect. Instead it always logs the following error-message:

[2022-12-02T13:22:49.483Z] INFO  my-service/CHANNELS: Reconnecting...
[2022-12-02T13:22:49.535Z] INFO  my-service/CHANNELS: AMQP is connected.
[2022-12-02T13:22:49.537Z] INFO  my-service/CHANNELS: AMQP channel created.
[2022-12-02T13:22:49.537Z] INFO  my-service/CHANNELS: Resubscribing to all channels...
[2022-12-02T13:22:49.540Z]
ERROR my-service/CHANNELS: Unable to connect AMQP server. MoleculerError: Already tracking active messages of channel my-service.my-service.something.done
    at AmqpAdapter.initChannelActiveMessages (/home/me/public_html/moleculer-channels-amqp-test/node_modules/@moleculer/channels/src/adapters/base.js:163:10)
    at AmqpAdapter.subscribe (/home/me/public_html/moleculer-channels-amqp-test/node_modules/@moleculer/channels/src/adapters/amqp.js:314:9)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async AmqpAdapter.resubscribeAllChannels (/home/me/public_html/moleculer-channels-amqp-test/node_modules/@moleculer/channels/src/adapters/amqp.js:496:4)
    at async AmqpAdapter.tryConnect (/home/me/public_html/moleculer-channels-amqp-test/node_modules/@moleculer/channels/src/adapters/amqp.js:215:4) {
  code: 500,
  type: undefined,
  data: undefined,
  retryable: false
}

Expected Behavior

As soon as the amqp-server is back online, the channels-module should reconnect to the server and start processing the waiting messages.

Failure Information

Steps to Reproduce

I've created a minimal-repo here: https://github.com/me23/moleculer-channels-amqp-test.git

  1. clone repos and change path to it
  2. if you don't have an Rabbitmq running on localhost you could start one with docker: docker-compose up
  3. start the service: node source/service.js
  4. restart rabbitmq: e.g. docker restart
  5. you get the error

    Context

Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.