Comments (15)
Hello,
I'm not a Java dev by trade and the trace is not super clear, but my best guess would be a file permission problem. See https://community.openhab.org/t/solved-mqtt-not-working/2064 for a similar issue.
I hope that helps.
from keycloak-event-listener-mqtt.
Neither am I and I'm just going to bash my way through the java to see if I can get it resolved and will feed back.
from keycloak-event-listener-mqtt.
I am also seeing this same issue with this extension, trying to send events over MQTT to confluent MQTT-proxy. Permissions issues seems unlikely but I could be way off. Looks like its using a simple in memory persistence object.
Edit: My situation was an admin event which doesnt use the MemoryPersistence object. So it very well could be a permissions issue.
from keycloak-event-listener-mqtt.
I am also seeing this same issue with this extension, trying to send events over MQTT to confluent MQTT-proxy. Permissions issues seems unlikely but I could be way off. Looks like its using a simple in memory persistence object.
Do you have a traceback you can share?
from keycloak-event-listener-mqtt.
14:04:50,938 INFO [stdout] (default task-2) UH OH!! MqttException (0)
14:04:50,939 ERROR [stderr] (default task-2) MqttException (0)
14:04:50,939 ERROR [stderr] (default task-2) at deployment.event-listener-mqtt-9.0.0-jar-with-dependencies.jar//org.eclipse.paho.client.mqttv3.persist.MqttDefaultFilePersistence.open(MqttDefaultFilePersistence.java:85)
14:04:50,940 ERROR [stderr] (default task-2) at deployment.event-listener-mqtt-9.0.0-jar-with-dependencies.jar//org.eclipse.paho.client.mqttv3.MqttAsyncClient.(MqttAsyncClient.java:469)
14:04:50,940 ERROR [stderr] (default task-2) at deployment.event-listener-mqtt-9.0.0-jar-with-dependencies.jar//org.eclipse.paho.client.mqttv3.MqttAsyncClient.(MqttAsyncClient.java:320)
14:04:50,940 ERROR [stderr] (default task-2) at deployment.event-listener-mqtt-9.0.0-jar-with-dependencies.jar//org.eclipse.paho.client.mqttv3.MqttAsyncClient.(MqttAsyncClient.java:315)
14:04:50,941 ERROR [stderr] (default task-2) at deployment.event-listener-mqtt-9.0.0-jar-with-dependencies.jar//org.eclipse.paho.client.mqttv3.MqttClient.(MqttClient.java:227)
14:04:50,941 ERROR [stderr] (default task-2) at deployment.event-listener-mqtt-9.0.0-jar-with-dependencies.jar//org.eclipse.paho.client.mqttv3.MqttClient.(MqttClient.java:138)
14:04:50,941 ERROR [stderr] (default task-2) at deployment.event-listener-mqtt-9.0.0-jar-with-dependencies.jar//org.softwarefactory.keycloak.providers.events.mqtt.MQTTEventListenerProvider.onEvent(MQTTEventListenerProvider.java:100)
14:04:50,942 ERROR [stderr] (default task-2) at [email protected]//org.keycloak.services.resources.admin.AdminEventBuilder.send(AdminEventBuilder.java:256)
14:04:50,942 ERROR [stderr] (default task-2) at [email protected]//org.keycloak.services.resources.admin.AdminEventBuilder.success(AdminEventBuilder.java:235)
14:04:50,942 ERROR [stderr] (default task-2) at [email protected]//org.keycloak.services.resources.admin.RealmAdminResource.updateRealmEventsConfig(RealmAdminResource.java:690)
14:04:50,943 ERROR [stderr] (default task-2) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
14:04:50,943 ERROR [stderr] (default task-2) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
14:04:50,943 ERROR [stderr] (default task-2) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
14:04:50,944 ERROR [stderr] (default task-2) at java.base/java.lang.reflect.Method.invoke(Method.java:566)
14:04:50,944 ERROR [stderr] (default task-2) at [email protected]//org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:138)
14:04:50,944 ERROR [stderr] (default task-2) at [email protected]//org.jboss.resteasy.core.ResourceMethodInvoker.internalInvokeOnTarget(ResourceMethodInvoker.java:517)
14:04:50,944 ERROR [stderr] (default task-2) at [email protected]//org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTargetAfterFilter(ResourceMethodInvoker.java:406)
14:04:50,945 ERROR [stderr] (default task-2) at [email protected]//org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invokeOnTarget$0(ResourceMethodInvoker.java:370)
14:04:50,945 ERROR [stderr] (default task-2) at [email protected]//org.jboss.resteasy.core.interception.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:356)
14:04:50,945 ERROR [stderr] (default task-2) at [email protected]//org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:372)
14:04:50,946 ERROR [stderr] (default task-2) at [email protected]//org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:344)
14:04:50,946 ERROR [stderr] (default task-2) at [email protected]//org.jboss.resteasy.core.ResourceLocatorInvoker.invokeOnTargetObject(ResourceLocatorInvoker.java:137)
14:04:50,946 ERROR [stderr] (default task-2) at [email protected]//org.jboss.resteasy.core.ResourceLocatorInvoker.invoke(ResourceLocatorInvoker.java:106)
14:04:50,946 ERROR [stderr] (default task-2) at [email protected]//org.jboss.resteasy.core.ResourceLocatorInvoker.invokeOnTargetObject(ResourceLocatorInvoker.java:132)
14:04:50,947 ERROR [stderr] (default task-2) at [email protected]//org.jboss.resteasy.core.ResourceLocatorInvoker.invoke(ResourceLocatorInvoker.java:100)
14:04:50,947 ERROR [stderr] (default task-2) at [email protected]//org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:440)
14:04:50,947 ERROR [stderr] (default task-2) at [email protected]//org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:229)
14:04:50,948 ERROR [stderr] (default task-2) at [email protected]//org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:135)
14:04:50,948 ERROR [stderr] (default task-2) at [email protected]//org.jboss.resteasy.core.interception.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:356)
14:04:50,948 ERROR [stderr] (default task-2) at [email protected]//org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:138)
14:04:50,949 ERROR [stderr] (default task-2) at [email protected]//org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:215)
14:04:50,949 ERROR [stderr] (default task-2) at [email protected]//org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:227)
14:04:50,949 ERROR [stderr] (default task-2) at [email protected]//org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
14:04:50,949 ERROR [stderr] (default task-2) at [email protected]//org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)
14:04:50,950 ERROR [stderr] (default task-2) at [email protected]//javax.servlet.http.HttpServlet.service(HttpServlet.java:590)
14:04:50,950 ERROR [stderr] (default task-2) at [email protected]//io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74)
14:04:50,950 ERROR [stderr] (default task-2) at [email protected]//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129)
14:04:50,951 ERROR [stderr] (default task-2) at [email protected]//org.keycloak.services.filters.KeycloakSessionServletFilter.doFilter(KeycloakSessionServletFilter.java:91)
14:04:50,951 ERROR [stderr] (default task-2) at [email protected]//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
14:04:50,951 ERROR [stderr] (default task-2) at [email protected]//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
14:04:50,952 ERROR [stderr] (default task-2) at [email protected]//io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)
14:04:50,952 ERROR [stderr] (default task-2) at [email protected]//io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
14:04:50,952 ERROR [stderr] (default task-2) at [email protected]//io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68)
14:04:50,953 ERROR [stderr] (default task-2) at [email protected]//io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
14:04:50,953 ERROR [stderr] (default task-2) at [email protected]//org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
14:04:50,953 ERROR [stderr] (default task-2) at [email protected]//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
14:04:50,954 ERROR [stderr] (default task-2) at [email protected]//io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68)
14:04:50,954 ERROR [stderr] (default task-2) at [email protected]//io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132)
14:04:50,954 ERROR [stderr] (default task-2) at [email protected]//io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
14:04:50,955 ERROR [stderr] (default task-2) at [email protected]//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
14:04:50,955 ERROR [stderr] (default task-2) at [email protected]//io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
14:04:50,955 ERROR [stderr] (default task-2) at [email protected]//io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
14:04:50,956 ERROR [stderr] (default task-2) at [email protected]//io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
14:04:50,956 ERROR [stderr] (default task-2) at [email protected]//io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
14:04:50,956 ERROR [stderr] (default task-2) at [email protected]//io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
14:04:50,957 ERROR [stderr] (default task-2) at [email protected]//io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
14:04:50,957 ERROR [stderr] (default task-2) at [email protected]//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
14:04:50,958 ERROR [stderr] (default task-2) at [email protected]//org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
14:04:50,958 ERROR [stderr] (default task-2) at [email protected]//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
14:04:50,958 ERROR [stderr] (default task-2) at [email protected]//org.wildfly.extension.undertow.deployment.GlobalRequestControllerHandler.handleRequest(GlobalRequestControllerHandler.java:68)
14:04:50,959 ERROR [stderr] (default task-2) at [email protected]//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
14:04:50,959 ERROR [stderr] (default task-2) at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269)
14:04:50,960 ERROR [stderr] (default task-2) at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78)
14:04:50,960 ERROR [stderr] (default task-2) at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133)
14:04:50,960 ERROR [stderr] (default task-2) at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130)
14:04:50,960 ERROR [stderr] (default task-2) at [email protected]//io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
14:04:50,961 ERROR [stderr] (default task-2) at [email protected]//io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
14:04:50,961 ERROR [stderr] (default task-2) at [email protected]//org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda$create$0(SecurityContextThreadSetupAction.java:105)
14:04:50,961 ERROR [stderr] (default task-2) at [email protected]//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1504)
14:04:50,962 ERROR [stderr] (default task-2) at [email protected]//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1504)
14:04:50,962 ERROR [stderr] (default task-2) at [email protected]//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1504)
14:04:50,962 ERROR [stderr] (default task-2) at [email protected]//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1504)
14:04:50,963 ERROR [stderr] (default task-2) at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249)
14:04:50,963 ERROR [stderr] (default task-2) at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78)
14:04:50,963 ERROR [stderr] (default task-2) at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99)
14:04:50,964 ERROR [stderr] (default task-2) at [email protected]//io.undertow.server.Connectors.executeRootHandler(Connectors.java:376)
14:04:50,964 ERROR [stderr] (default task-2) at [email protected]//io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:830)
14:04:50,964 ERROR [stderr] (default task-2) at [email protected]//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
14:04:50,964 ERROR [stderr] (default task-2) at [email protected]//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1982)
14:04:50,965 ERROR [stderr] (default task-2) at [email protected]//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
14:04:50,965 ERROR [stderr] (default task-2) at [email protected]//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
14:04:50,965 ERROR [stderr] (default task-2) at java.base/java.lang.Thread.run(Thread.java:834)
I have keycloak running in a docker container. I made a small modification to the admin event code to use in memory persistence and im going to test that out now.
from keycloak-event-listener-mqtt.
thanks for investigating! I still see a reference to org.eclipse.paho.client.mqttv3.persist.MqttDefaultFilePersistence.open in the traceback, hence why I suspect a file permission problem. The docker container might set tighter file permissions than expected.
(also even with an in-memory persistence, the mqtt client might need to be able to serialize data down to file to re-send events)
from keycloak-event-listener-mqtt.
I think its definitely a permission issue, by using the MemoryPersistence instance for admin events the problem goes away (as far as i can tell). I'm still dealing with a connection refused issue at the moment.
from keycloak-event-listener-mqtt.
I've faced with the same issue, KeyCloak v9 + this event listener, and get a "connection refused". After some investigation looks like listener use default value for mqtt serverUri parameter that leads to connection refused issue. I didn't get proper solution, but tried to hardcode my mqtt url, and seems it works. Hope it will be helpful for further debugging.
from keycloak-event-listener-mqtt.
I've faced with the same issue, KeyCloak v9 + this event listener, and get a "connection refused". After some investigation looks like listener use default value for mqtt serverUri parameter that leads to connection refused issue. I didn't get proper solution, but tried to hardcode my mqtt url, and seems it works. Hope it will be helpful for further debugging.
You can set the event listener's properties in standalone.xml next to the other SPI sections, like so:
<spi name="eventsListener">
<provider name="mqtt" enabled="true">
<properties>
<property name="serverUri" value="tcp://xxx:1883"/>
<property name="username" value="yyy"/>
<property name="password" value="zzz"/>
<property name="topic" value="keycloak"/>
</properties>
</provider>
</spi>
This was explained in the README.
from keycloak-event-listener-mqtt.
@mhuin I did, but it didn't work.
from keycloak-event-listener-mqtt.
Ok, there is my setup, anyone interested - feel free to try reproduce it:
- Run mosquitto as mqtt server:
docker run -it -p 1883:1883 -p 9001:9001 --name mqtt eclipse-mosquitto
- KeyCloak default config with added eventsListener SPI: https://termbin.com/y5dh
- KeyCloak Dockerfile that I used for testing:
FROM jboss/keycloak:9.0.0
COPY event-listener-mqtt-9.0.0-jar-with-dependencies.jar /opt/jboss/keycloak/standalone/deployments/.
# FIXME(mivanov) remove this config after manual testing
COPY standalone.xml /opt/jboss/keycloak/standalone/configuration/standalone.xml
built by: docker build -t test-keycloak --force-rm --no-cache --pull .
4) Run it:
docker run --rm -e KEYCLOAK_USER=admin -e KEYCLOAK_PASSWORD=password -p 8080:8080 --link mqtt test-keycloak:latest
5) Go to "Events" settings and enable mqtt event listener from it.
In my case it tried to connect via tcp://localhost:1883
, that causes Connection refused (32103)
I've discovered it accidentally when tried to get serverUri in logs for debug purposes
from keycloak-event-listener-mqtt.
@ivanovmi I think your problem is the permissions of standalone.xml after the copy, they change during the copy in my experience and can no longer be read by keycloak.
from keycloak-event-listener-mqtt.
@hitchan good point, thank you. I've updated permissions/ownership to be consistent with base image, but still get the same connection refused error, with the same default serverUri in connection string.
from keycloak-event-listener-mqtt.
@ivanovmi @hitchan
in docker, standalone-ha.xml
is used by default, if you really want to use standalone.xml
append docker cmd -c=standalone.xml
see:
keycloak docker image entrypoint shell script
notice:
# If the server configuration parameter is not present, append the HA profile.
if echo "$@" | grep -E -v -- '-c |-c=|--server-config |--server-config='; then
SYS_PROPS+=" -c=standalone-ha.xml"
fi
from keycloak-event-listener-mqtt.
Apologies for the late resolution. I believe the issue is fixed in the latest release. Thanks to @xaralis for their help in solving the issue!
from keycloak-event-listener-mqtt.
Related Issues (9)
- updating standalone.xml causes keycloak not to start HOT 15
- Cannot run keycloak with it 21.0.1 HOT 4
- Publisher ID cause session conflict when Keycloak has more one node. HOT 3
- UH OH!! MqttException (0) : Message not send after user update HOT 2
- Verbose logging of event listener configuration HOT 3
- not always create new connection on every event HOT 2
- Typo in README.md HOT 2
- Representation field missing in Admin Event
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from keycloak-event-listener-mqtt.