While trying to make an outbound request to an external API from Google Cloud Run fully managed, the http call gets stuck somehow or we are running into the following SSLHandshakeException Remote host terminated the handshake after a little while. The image works well when executed locally so I assume this comes from the sandboxed cloud run environment.
My docker configuration:
FROM maven:3.6.3-jdk-11 as builder
WORKDIR /app
COPY pom.xml .
COPY src ./src
# Build a release artifact.
RUN mvn package -DskipTests
FROM openjdk:11-jdk
COPY --from=builder /app/target/poc-*.jar /poc.jar
# Run the service on container startup.
CMD ["java","-Djava.security.egd=file:/dev/./urandom","-Dserver.port=${PORT}","-jar","/poc.jar"]
The snippet of code getting stuck:
private HttpEntity<String> prepareSecuredRestCallToAJStage() {
CredentialsDTO credentials = new CredentialsDTO(USERNAME, PASSWORD);
// Getting stuck here
TokenDTO response = restTemplate.postForObject(LOGIN_CHECK_URL, credentials, TokenDTO.class);
// We never get the response
String token = BEARER_TOKEN_PREFIX + Objects.requireNonNull(response).getToken();
}
For information, this is a Spring Boot application and we are getting this trace at startup:Container Sandbox: Unsupported syscall setsockopt(0x9,0x6,0x6,0x3e7a3d678e2c,0x4,0xa)
Is there something I'm missing?