0

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.

1 Answer 1

1

Was resolved. I added thread monitor that invoke stop method of thread reading response.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.