Skip to content

Conversation

@codomposer
Copy link
Contributor

@codomposer codomposer commented Oct 30, 2025

Fix: Recreate RabbitMQ bindings on connection failure

Fixes

Closes #1469
Closes #393
Closes #436

Problem

When RabbitMQ goes down and comes back up, the Socket.IO servers enter a split-brain state where they can send events but never receive them. This occurs because:

  1. Exchange/queue bindings are created once before the listening loop
  2. When RabbitMQ restarts, these bindings become invalid
  3. The retry logic reconnects but reuses the stale queue/exchange references
  4. Messages can be published (new connections work) but never consumed (old bindings are dead)

This results in servers that appear healthy but silently fail to process incoming events.

Root Cause

When RabbitMQ goes down and comes back up, Socket.IO servers enter a split-brain state where they can send events but never receive them.

Solution

Move the exchange/queue binding creation inside the retry loop so they are recreated on every connection failure.

Result

When RabbitMQ restarts, the exception triggers a retry that creates fresh connection, channel, exchange, and queue objects with valid bindings. Servers can now both send and receive events after recovery.

@miguelgrinberg
Copy link
Owner

Looks good, thanks!

@miguelgrinberg miguelgrinberg merged commit c52e93b into miguelgrinberg:main Oct 30, 2025
25 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

recreate bindings on failures ValueError('Unexpected binary attachment') on Client Intermittent long delay during connection upgrade

2 participants