totalcross
totalcross copied to clipboard
HTTP request doesn't work with Zulu JDK 11, but it does with Oracle JDK 8
Describe the bug
This might be related to #83. the class totalcross.io.HttpStream is not working properly when making a GET call to an HTTPS address. The socket is being closed before response is read. A working workaround is to use the Oracle JDK 8 that comes with the sun libraries. By using the Zulu JDK 11 the behaviour is buggy.
To Reproduce
HttpStream.Options options = new HttpStream.Options();
options.openTimeOut = options.readTimeOut = options.writeTimeOut = 60_000;
if(BASE_URL.startsWith("https://")) {
options.socketFactory = new SSLSocketFactory();
}
try (HttpStream hs = new HttpStream(new URI(BASE_URL + SOME_ENDPOINT + "?some_parameter=" + value), options)) {
JSONObject ret = readJsonObject(hs);
boolean isValid = (boolean) ret.get("isValid");
if(!isValid) {
config.remove("uuid");
}
return isValid;
} catch (IOException e1) {
e1.printStackTrace();
}
// returning avoids uuid to be changed if something goes wrong with the request
return true;
Actual behavior
totalcross.io.IOException: Socket input is already shutdown
at totalcross.net.ssl.SSL.read(SSL.java:273)
at totalcross.net.ssl.SSLSocket.readBytes(SSLSocket.java:102)
at totalcross.net.HttpStream.readBytes(HttpStream.java:635)
at totalcross.io.ByteArrayStream.readFully(ByteArrayStream.java:301)
Expected behavior
Making a HTTP GET request with query parameters to an HTTPS endpoint without getting any error when reading the response.
Devices:
Please complete the following information:
- Launcher Java
@ItaloYeltsin you need #148 to close this issue?
Nope, this a problem on TotalCross HttpStream class on the development environment.