jhipster / generator-jhipster-quarkus

Quarkus blueprint for JHipster
https://www.jhipster.tech/blueprints/quarkus/
Apache License 2.0
141 stars 56 forks source link

Unable to connect to Keycloak when running in a container #284

Closed ivanatdevoteam closed 1 year ago

ivanatdevoteam commented 1 year ago

Describe the bug So i am running the quarkus application inside a docker container. I have copied all oauth2 environment variables from the application.properties to the docker-compose. I have also inserted "keycloak" inside my hosts file. Whenever i start the app i get the following error in the console

WARN  [io.qua.oid.com.run.OidcCommonUtils] (vert.x-eventloop-thread-1) OIDC Server is not available:: io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: keycloak/127.0.0.1:9080
docker-quarkusdemo-app-1  | Caused by: java.net.ConnectException: Connection refused
docker-quarkusdemo-app-1  |     at java.base/sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
docker-quarkusdemo-app-1  |     at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:777)
docker-quarkusdemo-app-1  |     at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:337)
docker-quarkusdemo-app-1  |     at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:334)
docker-quarkusdemo-app-1  |     at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:776)
docker-quarkusdemo-app-1  |     at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724)docker-quarkusdemo-app-1  |     at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650)
docker-quarkusdemo-app-1  |     at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562)
docker-quarkusdemo-app-1  |     at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
docker-quarkusdemo-app-1  |     at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
docker-quarkusdemo-app-1  |     at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)docker-quarkusdemo-app-1  |     at java.base/java.lang.Thread.run(Thread.java:829)

The app starts normaly but then when i try to login i am redirected to http://localhost:8080/oauth2/authorization/oidc and recieve the following response {"status":401,"title":"Unauthorized","instance":"/oauth2/authorization/oidc"}

Screenshots This is how my docker-compose for the app looks like: image

I have not changed anything in the docker compose for mariadb or keycloak. I have also just removed the jhipster registry.

Additional context running on the main branch of the quarkus blueprint

EDIT: I reset the docker compose to its original state and just fixed the links to my keycloak and database inside application.properties and everything works