I am trying to call a URL within a java (javafx) application for performing some actions (unzip a zip file), however i am getting (in some cases that i can not identify) an error.
Here is the code:
public void JavaHttpsUrlConnectionReader(String myUrl) throws Exception {
URL url = null;
BufferedReader reader = null;
StringBuilder stringBuilder;
try {
url = new URL(myUrl);
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
connection.setRequestMethod("GET");
// give it 120 seconds to respond
connection.setReadTimeout(120*1000);
connection.connect();
// read the output from the server
reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
stringBuilder = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null)
{
stringBuilder.append(line + "\n");
}
}
catch (Exception e)
{
e.printStackTrace();
throw e;
}
finally
{
// close the reader; this can throw an exception too, so
// wrap it in another try/catch block.
if (reader != null)
{
try
{
reader.close();
}
catch (IOException ioe)
{
ioe.printStackTrace();
}
}
}
}
and here is the exception i get:
2015-04-17 12:39:34 INFO TranferFileFtp4j:403 - >> Going to cal url: https://testonline.npapan.com/mcp_unzip.aspx?id=5898
2015-04-17 12:39:35 ERROR FXMLDocumentController:104 -
java.net.SocketException: Connection reset at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at sun.security.ssl.InputRecord.readFully(Unknown Source)
at sun.security.ssl.InputRecord.read(Unknown Source)
at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.afterConnect(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(Unknown Source)
at com.npap.network.TranferFileFtp4j.JavaHttpsUrlConnectionReader(TranferFileFtp4j.java:905)
at com.npap.network.TranferFileFtp4j.renameFileFtps1(TranferFileFtp4j.java:404)
at com.npap.utils.ProcessDicomFiles.sendZippFiles(ProcessDicomFiles.java:229)
at com.npap.scheduler.MainJob.execute(MainJob.java:97)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
I guess it is not a timeout issue (since the message does not indicate such a case), however anyone guessing what may cause this timeout issues?