1

I have a simple micronaut app.

I have two separate endpoints where the method that executes will call an API using a client (I've tried both the http client from "java.net.http.HttpClient" and "io.micronaut.http.client.RxHttpClient" but the same issue happens).

When you hit any of the endpoints after starting the app, the function will execute as expected, where the client calls an external API and retrieves the response as a string. If you try to hit that same endpoint again, it will throw:

"javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure."

I don't think this is an issue on the API's server side for the following reasons:

  1. This issue happens when I hit two separate endpoints with two separate external APIs
  2. The request goes through the first time no problem
  3. I can hit the same APIs in postman without error - it's just when I call them with the client that there is an issue.

My controller:

import io.micronaut.http.annotation.Controller;
import io.micronaut.http.annotation.Get;
import io.micronaut.http.HttpResponse;


import javax.inject.Inject;
import java.io.IOException;

import static io.micronaut.http.HttpRequest.GET;

@Controller("/api")
public class DeckController {

    @Inject
    private DeckService deckService;

    @Get(value = "/drawRx")
    public  HttpResponse<Card> drawCardRx(){
        deckService.drawCardRx("ijhhxvxwn63g",1);
        return HttpResponse.ok();
    }
}

One of my services where the client calls the API:

public void drawCardRx(String deckId, int amount){

    final String newDeckUrl = "/deck/"+deckId+"/draw/?count="+amount;
    Disposable result = this.httpClient
            .retrieve( GET(newDeckUrl))
            .subscribe(data -> System.out.println(data));
    
    return;
}

Like I said, the first time I hit the endpoint, the response is returned from the server without a problem.

I've tried the below articles and followed those steps, but no improvement.

https://www.baeldung.com/java-ssl-handshake-failures

How to solve javax.net.ssl.SSLHandshakeException Error?

Is there something I am missing?

jpz
  • 11
  • 1

0 Answers0