should not reconnect if credentials are bad
Closed this issue · 4 comments
on_disconnect should raise error and not reconnect if login and password are incorrect.
The problem is that it's not that simple with AMQP, since it doesn't require brokers to raise an error on authentication failures, they just close the connection. But that can happen at any point down the line as well.
So it pretty much boils down on the handshake of Start and StartOk where some sort of state could be stored, but that again doesn't seem very EventMachine-y. That state could be checked in on_disconnect. Personally I don't want my clients to bitterly fail, since I might have no way to bring them back up again, but in any way it could prevent the client from hammering the broker, and at least log a decent message.
Until there's a reasonable solution, you could do what I'm doing ATM, I'd suggest looking into this commit: http://github.com/melito/amqp/commit/e206ee1c03743e32d85b80c0c2cf7f2142ff5416. That's what we're using right now, but I'm not entirely happy with it.
Bump, this is biting me too.
I'd suggest to init the @on_disconnect hook after the connection was established (so just after we send Connection.Tune-Ok or maybe Connection.Open). If the connection wasn't established, I don't think we should try to reconnect. I'll take a look.
Fixed in ruby-amqp@6dc4f48