dart_amqp
dart_amqp copied to clipboard
FatalException thrown when multiple connection attempts made to an offline server that suddenly comes online.
// test.dart
var client = new amqp.Client(settings: amqp.ConnectionSettings(
host : 'localhost',
port : 5672,
maxConnectionAttempts: 99999, // -- "infinite" retries because setting this to 0 or -1 isn't supported
authProvider : amqp.PlainAuthenticator('username', 'password'),
));
await client.connect();
With the rabbit instance stopped, start the above dart script. Let it make a couple unsuccessful attempts / retries, and then start the rabbit instance. As soon as it comes online, notice the FatalException
thrown by the AMQP client.
dart run ./test.dart
INFO: 2022-01-04 11:07:16.902302: dart_amqp.Connection: Trying to connect to localhost:5672 [attempt 1/99999]
INFO: 2022-01-04 11:07:20.509093: dart_amqp.Connection: Trying to connect to localhost:5672 [attempt 2/99999]
INFO: 2022-01-04 11:07:24.066724: dart_amqp.Connection: Trying to connect to localhost:5672 [attempt 3/99999]
Unhandled exception:
FatalException: Lost connection to the server
SEVERE : 2022-01-04 11:07:24.588279: dart_amqp.Connection: FatalException: Lost connection to the server
Process finished with exit code 255