Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection recovery fails and gives up even though recovery policy is recoverAlways() #91

Open
amertahir opened this issue Apr 6, 2023 · 1 comment

Comments

@amertahir
Copy link

amertahir commented Apr 6, 2023

After several attempts at recovery, the recovery fails on java.net.ConnectException:

[lyra-recovery-1] ERROR n.j.lyra.internal.ConnectionHandler - Failed to recover connection cxn-3
java.net.ConnectException: Connection refused (Connection refused)
	at java.base/java.net.PlainSocketImpl.socketConnect(Native Method)
	at java.base/java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
	at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
	at java.base/java.net.AbstractPlainSocketImpl.connect(Unknown Source)
	at java.base/java.net.SocksSocketImpl.connect(Unknown Source)
	at java.base/java.net.Socket.connect(Unknown Source)
	at com.rabbitmq.client.impl.SocketFrameHandlerFactory.create(SocketFrameHandlerFactory.java:60)
	at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1137)
	at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1087)
	at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1027)
	at net.jodah.lyra.internal.ConnectionHandler$3.call(ConnectionHandler.java:243)
	at net.jodah.lyra.internal.ConnectionHandler$3.call(ConnectionHandler.java:236)
	at net.jodah.lyra.internal.RetryableResource.callWithRetries(RetryableResource.java:51)
	at net.jodah.lyra.internal.ConnectionHandler.createConnection(ConnectionHandler.java:236)
	at net.jodah.lyra.internal.ConnectionHandler.recoverConnection(ConnectionHandler.java:273)
	at net.jodah.lyra.internal.ConnectionHandler.access$100(ConnectionHandler.java:39)
	at net.jodah.lyra.internal.ConnectionHandler$ConnectionShutdownListener$1.run(ConnectionHandler.java:95)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)

The connection retry and recovery policies are set to always retry and recover:

Config lyraConf = new Config()
    .withRecoveryPolicy(RecoveryPolicies.recoverAlways().withBackoff(Duration.seconds(1), Duration.seconds(20)))
    .withRetryPolicy(RetryPolicies.retryAlways().withBackoff(Duration.seconds(1), Duration.seconds(20)));

ConnectionOptions options = new ConnectionOptions(factory);
myClass.setConnection(Connections.create(options, lyraConf));
@acogoluegnes
Copy link
Collaborator

We don't have enough information to help. Please provide a standalone project and steps to reproduce the issue.

Note Lyra is no longer maintained, you should use the RabbitMQ Java client, which provide automatic connection and topology recovery.

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

No branches or pull requests

2 participants