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
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
request.disconnect(); // Still fails with or without this line._