Skip to content

AMQP plugin loses connection to RabbitMQ #36

@schreiberstein

Description

@schreiberstein

Greetings,

first of, thank you very much for the creation of this plugin and your continued efforts.

I am currently experiencing issues when the plugin is active, causing Keycloak to throw error 500 to user requests due to the plugin losing its connection to the upstream RabbitMQ server.

Setup:

  • Debian GNU/Linux Docker host (amd64)
  • Keycloak 26.2
  • RabbitMQ 4.1 (direct AMQP connection, no SSL)
  • Plugin version 0.9.1 (latest available binary)
  • Both containers run on the same host, in the same docker-compose stack, in the same network (= no networking issues, no firewall)

After a couple of requests, I receive the following stack traces in the Keycloack Docker log (the client application receives HTTP code 500).

Error:
2025-06-18 12:58:30,036 ERROR [org.keycloak.services.error.KeycloakErrorHandler] (executor-thread-301) Uncaught server error: java.io.IOException at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:140) at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:136) at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:158) at com.rabbitmq.client.impl.ChannelN.open(ChannelN.java:136) at com.rabbitmq.client.impl.ChannelManager.createChannel(ChannelManager.java:189) at com.rabbitmq.client.impl.AMQConnection.createChannel(AMQConnection.java:638) at com.rabbitmq.client.impl.recovery.AutorecoveringConnection.createChannel(AutorecoveringConnection.java:174) at com.vymalo.keycloak.webhook.AmqpWebhookHandler.initHandler(AmqpWebhookHandler.kt:139) at com.vymalo.keycloak.webhook.AbstractWebhookEventListenerFactory.ensureParametersInit(AbstractWebhookEventListenerFactory.kt:39) at com.vymalo.keycloak.webhook.AbstractWebhookEventListenerFactory.create(AbstractWebhookEventListenerFactory.kt:32) at com.vymalo.keycloak.webhook.AbstractWebhookEventListenerFactory.create(AbstractWebhookEventListenerFactory.kt:16) at org.keycloak.services.DefaultKeycloakSession.getOrCreateProvider(DefaultKeycloakSession.java:184) at org.keycloak.services.DefaultKeycloakSession.getProvider(DefaultKeycloakSession.java:195) at org.keycloak.models.KeycloakBeanProducer_ProducerMethod_getKeycloakSession_XoSEUTXOsE3bpqXlGMAykCiECUM_ClientProxy.getProvider(Unknown Source) at org.keycloak.events.EventBuilder.lambda$getEventListeners$1(EventBuilder.java:94) at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179) at java.base/java.util.HashMap$ValueSpliterator.forEachRemaining(HashMap.java:1787) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:575) at java.base/java.util.stream.AbstractPipeline.evaluateToArrayNode(AbstractPipeline.java:260) at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:616) at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:622) at java.base/java.util.stream.ReferencePipeline.toList(ReferencePipeline.java:627) at org.keycloak.events.EventBuilder.getEventListeners(EventBuilder.java:96) at org.keycloak.events.EventBuilder.<init>(EventBuilder.java:74) at org.keycloak.events.EventBuilder.<init>(EventBuilder.java:62) at org.keycloak.services.resources.RealmsResource.getProtocol(RealmsResource.java:117) at org.keycloak.services.resources.RealmsResource$quarkusrestinvoker$getProtocol_b2af2a2de155d6f3564a200a8d3634cdf6f57aa2.invoke(Unknown Source) at org.jboss.resteasy.reactive.server.handlers.InvocationHandler.handle(InvocationHandler.java:29) at io.quarkus.resteasy.reactive.server.runtime.QuarkusResteasyReactiveRequestContext.invokeHandler(QuarkusResteasyReactiveRequestContext.java:141) at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:147) at io.quarkus.vertx.core.runtime.VertxCoreRecorder$15.runWith(VertxCoreRecorder.java:638) at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2675) at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2654) at org.jboss.threads.EnhancedQueueExecutor.runThreadBody(EnhancedQueueExecutor.java:1627) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1594) at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:11) at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:11) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.base/java.lang.Thread.run(Thread.java:1583) Caused by: com.rabbitmq.client.ShutdownSignalException: clean connection shutdown; protocol method: #method<connection.close>(reply-code=200, reply-text=OK, class-id=0, method-id=0) at com.rabbitmq.utility.ValueOrException.getValue(ValueOrException.java:66) at com.rabbitmq.utility.BlockingValueOrException.uninterruptibleGetValue(BlockingValueOrException.java:36) at com.rabbitmq.client.impl.AMQChannel$BlockingRpcContinuation.getReply(AMQChannel.java:552) at com.rabbitmq.client.impl.AMQChannel.privateRpc(AMQChannel.java:316) at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:152) ... 39 more

I already tried to increase the RabbitMQ heartbeat frequency in the RabbitMQ configuration (heartbeat = 5) but I still encounter the same problem.

Do you have any idea why this happens?
By the way, wouldn't it be more practical to have an option to make this fail gracefully, that is, not return code 500 to the client application? (i.e. via an option set by an environment variable)
I would appreciate any input on that.

Thank you!

Sincerely,
Alexander Schreiber (schreiberstein)

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions