I have problem with socket inputstream reading. Before reading I set timeout for HttpClient
connectionManager.getParams().setSoTimeout(1000*10);
connectionManager.getParams().setConnectionTimeout(1000*10);
HttpClient client = new HttpClient(connectionManager);
Try to read response stream and instead SocketTimeoutException I getting block on read() method.
client.executeMethod(method);
InputStream stream = method.getResponseBodyAsStream();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
int read;
byte[] bytes = new byte[1024];
while ((read = stream.read(bytes)) != -1) {
baos.write(bytes, 0, read);
}
} catch (Throwable e) {
e.printStackTrace();
} finally {
try {
baos.close();
stream.close();
} catch (Throwable e) {
e.printStackTrace();
}
}
How can I read input stream without blocks and why soTimeout not working ?
Thanks a lot.