Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handshake_failure Exception #218

Open
rlingeh opened this issue Jun 21, 2023 · 0 comments
Open

Handshake_failure Exception #218

rlingeh opened this issue Jun 21, 2023 · 0 comments

Comments

@rlingeh
Copy link

rlingeh commented Jun 21, 2023

I get a Handshake error exception when I try to connect more than once to get exchange rates. The first connection always works but the second will fail. The first connection can have the endpoint
"https://api.exchangerate.host/convert?from=USD&to=EUR", this will succeed and if I try again with the same endpoint or a different one like "https://api.exchangerate.host/convert?from=USD&to=XAF", it fails. If I restart my application, the first connection works again.
It looks like I am doing something wrong. I noticed that so long as my app is up I can only connect once. Here is my code:

_String endpoint =
URL url = new URL(endpoint);
HttpURLConnection request = (HttpURLConnection) url.openConnection();
request.connect(); // fails here by second connection

JsonParser jp = new JsonParser();
JsonElement root = jp.parse(new InputStreamReader((InputStream) request.getContent()));
JsonObject jsonobj = root.getAsJsonObject();

request.disconnect(); // Still fails with or without this line._

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant