- Newest
- Most votes
- Most comments
The "Connection reset by peer" errors you're experiencing with your Amazon MQ for RabbitMQ cluster could be caused by several factors:
-
Network issues: Intermittent network connectivity problems between your clients and the RabbitMQ cluster could cause connection resets.
-
Memory pressure: If the RabbitMQ broker is experiencing high memory usage, it might trigger memory alarms that affect client connections. When RabbitMQ raises a high memory alarm (when RabbitMQMemUsed exceeds RabbitMQMemLimit), it can impact connections.
-
Disk space issues: Similar to memory alarms, disk alarms can be triggered when there's a high number of unconsumed messages while new messages are being added, potentially affecting connections.
-
Connection/channel limits: Your cluster might be hitting connection or channel limits. For an m5.large instance, there are limits on connections (5,000) and channels (15,000).
-
Client-side issues: Your client library might not be properly handling connection recovery.
To further debug the problem:
-
Monitor CloudWatch metrics: Regularly check memory usage (RabbitMQMemUsed and RabbitMQMemLimit) and disk usage (RabbitMQDiskFree and RabbitMQDiskFreeLimit) metrics to identify potential resource constraints.
-
Implement automatic network recovery: Ensure your client code properly implements automatic network recovery. While you're using aiopika, make sure it's configured to handle connection failures and recovery.
-
Implement retry logic: Add retry logic for initial connection failures in your client code.
-
Check queue synchronization: If you're experiencing issues during maintenance windows, it could be related to queue synchronization. Consider adjusting the ha-sync-batch-size if synchronization is pausing.
-
Review client heartbeat settings: You mentioned a heartbeat of 60 seconds in your connection string. Consider adjusting this value to detect connection issues earlier.
-
Examine connection patterns: Look for patterns in when these errors occur - are they happening during specific operations, at certain times of day, or during maintenance windows?
-
Check for broker restarts: AWS might be performing maintenance on the cluster nodes, which could temporarily affect connections.
Since you mentioned this doesn't happen in your self-managed RabbitMQ cluster, it might be related to how Amazon MQ manages the RabbitMQ service, particularly around maintenance windows or resource management.
Sources
Amazon MQ for RabbitMQ sizing guidelines - Amazon MQ
Troubleshooting Amazon MQ - Amazon MQ
Resolving RabbitMQ paused queue synchronization - Amazon MQ
Best practices for network resilience and monitoring in Amazon MQ for RabbitMQ - Amazon MQ
answered 10 months ago
Once in a while some containers would restart because RabbitMQ connection breaks Server connection reset: ConnectionResetError(104, 'Connection reset by peer') and our client does not recover (until container starts new).
Amazon MQ recommends always enabling automatic network recovery [1] to prevent significant downtime in cases where client connections to RabbitMQ nodes fail.
Disconnections can happen for a variety of normal and expected reasons, like during Amazon MQ broker maintenance window [2] restarts or during instance type [3] upgrades. Please update your client application code to retry connections on disconnect instead of only once on container startup.
[1] https://docs.aws.amazon.com/amazon-mq/latest/developer-guide/best-practices-network-resilience.html [2] https://docs.aws.amazon.com/amazon-mq/latest/developer-guide/maintaining-brokers.html [3] https://docs.aws.amazon.com/amazon-mq/latest/developer-guide/upgrading-instance-type.html
answered 10 months ago
Relevant content
asked 2 years ago
asked 5 years ago

Brokers's metrics (CPU, Memory usage) looks the same and healthy