RabbitMQ Stream Exception using a Dockerized Spring Boot Application - spring

When starting up Spring Boot I get the following error:
Failed to start bean
'org.springframework.amqp.rabbit.config.internalRabbitListenerEndpointRegistry';
nested exception is com.rabbitmq.stream.StreamException
and the cause of the error is:
java.net.UnknownHostException: 4e31343111e9: Temporary failure in name
resolution
The authentication passes fine for RabbitMQ - if I change the credentials then it fails at that before even reaching this stage.
Spring Boot is running using a Docker container and the RabbitMQ host is also on another host running in a container (with 5552 port open).

The error was that there was no advertised host and port for streams in the rabbit instance - this was resolved once that was added as the explicit host IP address.

Related

ERROR io.opentelemetry.exporter.internal.grpc.OkHttpGrpcExporter

I am trying to connect my application to Signoz. It only works when both application and Signoz are running in the same machine. If I pull the application in another machine, I am getting timed out error.
ERROR io.opentelemetry.exporter.internal.grpc.OkHttpGrpcExporter - Failed to export spans. The request could not be executed. Full error message: connect timed out
My application is deployed in Wildfly so I have add the following JAVA_OPTS to the standalone.conf.bat
set "JAVA_OPTS=%JAVA_OPTS% -javaagent:c:/signoz/opentelemetry-javaagent.jar -Dotel.metrics.exporter=none -Dotel.exporter.otlp.endpoint=http://MyOtherServer:4318 -Dotel.resource.attributes=""service.name=MyService"""
opentelemetry-javaagent by default expects gRPC protocol that is usualy listening on port 4317.
If your collector listens on 4318, it is otlp-http. That means you must also set
-Dotel.exporter.otlp.protocol=http/protobuf
Source: https://github.com/open-telemetry/opentelemetry-java/blob/main/sdk-extensions/autoconfigure/README.md#otlp-exporter-span-metric-and-log-exporters

How do I make plugin.identity.keycloak from Camunda work in Docker (Desktop)?

About a month ago, I implemented camunda-bpm-identity-keycloak as described here to make my spring-camunda project work with keycloak. This week I tried dockerizing both keycloak and spring-camunda. While the former has been implemented without much hindrance, the latter I´m stuck on for days now.
The main problem is about the api calls seemingly not reaching keycloak, no matter if keycloak is dockerized or not. I could solve that issue for the SSO part. However, this problem is still remaining in the "plugin.identity.keycloak" part.
Here is the error code in docker.
2022-03-10 13:39:45.704 ERROR 1 --- [ main] org.camunda.bpm.extension.keycloak : KEYCLOAK-01011 TOKEN request failed: I/O error on POST request for "https://localhost:8443/auth/realms/MyRealm/protocol/openid-connect/token"
Here are its properties in the .yaml file:
plugin.identity.keycloak:
keycloakIssuerUrl: https://localhost:8443/auth/realms/MyRealm
keycloakAdminUrl: https://localhost:8443/auth/admin/realms/MyRealm
clientId: myrealm-client
clientSecret: insertsecret
useUsernameAsCamundaUserId: true
useGroupPathAsCamundaGroupId: true
administratorGroupName: camunda-admin
disable-s-s-l-certificate-validation: true
Here is the Dockerfile:
FROM adoptopenjdk/openjdk11:alpine-jre
EXPOSE 8080
ARG JAR_FILE=target/testdockerforspringcamunda-1.0.0-SNAPSHOT.jar
ADD ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
Edit:
I have no docker compose to share. I just used that Dockerfile. The strange thing is that it gets an error during the POST request for the token instead of during the Get request for the configuration. When I start the dockerized project while keycloak is offline, the latter happens.
Here are the configured keycloak ports of the non dockerized keycloak standalone server:
<socket-binding name="http" port="${jboss.http.port:8180}"/>
<socket-binding name="https" port="${jboss.https.port:8443}"/>
Edit2:
After using the containername instead the localhost, I get a slightly different error:
2022-03-14 10:28:13.651 ERROR 1 --- [ main] org.camunda.bpm.extension.keycloak : KEYCLOAK-01011 TOKEN request failed: I/O error on POST request for "https://keycloak3:8181/auth/realms/MyRealm/protocol/openid-connect/token": keycloak: System error; nested exception is java.net.UnknownHostException: keycloak: System error
Edit3:
I somehow solved this new error. I assume restarting the keycloak container did that.
When you are working in containers, localhost resolves to the local container.
In your case invoking keycloak using localhost from camunda container wont reach anywhere.
The problem with the service name is, that it works fine in container-to-container communication. But when it comes to browser redirection, it wont work.
Use your system IP address it works fine.

Cloud Run: deploying spring docker image causing error; Failed to start and then listen on the port defined by the PORT environment variable

I am trying to deploy spring boot docker image stored at Docker Registry to Cloud Run.
However, when I deployed the image, I got the error;
Cloud Run error: Container failed to start. Failed to start and then listen on the port defined by the PORT environment variable. Logs for this revision might contain more information.
I understand this could be caused by port and address setting, so I fixed these parts referring the official doc, though still experiencing the same error. Concretely, I set these things as below, on application.yml.
server:
port: ${PORT:8080}
address: ${ADDRESS:localhost}
I understand PORT variable would be passed by Cloud Run(in my case, port num is set to 8080 on Cloud Run). And also ADDRESS will be passed to by myself(the value is 0.0.0.0, referring the official doc).
For reference, the below is my Dockerfile building spring boot docker image;
# Stage1 - execute build process
FROM openjdk:14-jdk-alpine as build_process
WORKDIR /back_end
COPY . .
RUN ./gradlew build -x test
# Stage2 - boot app with the build output above
FROM openjdk:14-jdk-alpine
EXPOSE ${PORT}
COPY --from=build_process /back_end/build/libs/back_end-0.0.1-SNAPSHOT.jar ./app.jar
RUN adduser -D user
USER user
ENTRYPOINT ["sh","-c","java -jar app.jar"]
Any help would be really appreciated. Thank you so much for reading!
I figured it out why my docker image had failed Cloud Run's health check. After all, it is not about Port and IP address, but about the timing when the health check process executes.
The health check process seems to start immediately once the image is deployed, though my case it took almost 30 secs to launch spring boot tomcat server after deploying to Cloud Run.
That led to the failure of the health check process, so I fixed settings to launch tomcat server immediately too, which solved the issue I posted.

Spring Boot 1.5.8 server.port:0 already in use

Environment: Mac OSX 10.13 IntelliJ IDEA 2017.2.5
I have set server.port=0 within the application properties. The problem is Java keeps trying ports that are already in use.
Error: Exception thrown by the agent : java.rmi.server.ExportException: Port already in use: 51939; nested exception is:
java.net.BindException: Address already in use
Process finished with exit code 1
How to make sure Java does not select a used port?

Getting NettyTcpClient connection error with Spring WebSocket with amqp broker (rabbitmq) while running in docker

I am trying to use the rabbitmq as the StompBroker in the WebSocketConfig. Have added the dependencies reactor-core and reactor-net
It works fine when starting up locally (localhost) but when I try to start the project as a docker container (rabbitmq image is correctly built with STOMP plugin), I get below error.
r.io.net.impl.netty.tcp.NettyTcpClient : Failed to connect to /127.0.0.1:61613. Attempting reconnect in 5000ms
I tried setting the setRelayHost("rabbitmq") and setRelayPort(61613) (since rabbitmq is the service name in the docker compose, using it to resolve the host name). No luck still.

Resources