Skip to content

Raise MaxReconnectAttemptsExceededError #735

@negativeOne1

Description

@negativeOne1

Proposed change

Raise an Error when the client has exceeded the configured max_reconnect_attempts for all servers in the connection pool.

Use case

async def connect_to_nats():
      nc = NATS()
      try:
          await nc.connect(
              servers=["nats://nats1:4222", "nats://nats2:4222"],
              max_reconnect_attempts=10,
              reconnect_time_wait=2
          )
      except nats.errors.MaxReconnectAttemptsExceededError as e:
          # Definitive permanent failure - all retries exhausted
          logger.critical(f"NATS permanently failed after {e.max_attempts} attempts")

Contribution

I have a proposal for the code change.

Metadata

Metadata

Assignees

Labels

proposalEnhancement idea or proposal

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions