HttpUrlConnection setConnectTimeout doesn't work?
<p>I'm trying to get use of setConnectTimeout function like this:</p>

<pre><code>protected HttpURLConnection getConnection() throws SocketTimeoutException, IOException{
    Log.d("HTTPRequest", address);
    URL page = new URL(address);
    HttpURLConnection connection = (HttpURLConnection) page.openConnection();

    connection.setUseCaches(cacheResult);
    connection.setConnectTimeout(3000);
    connection.connect();
    return connection;
}
</code></pre>

<p>and then:</p>

<pre><code>public String getTextData() throws InternetConnectionUnavailableException {
    try{
        HttpURLConnection conn = getConnection();
        StringBuffer text = new StringBuffer();
        InputStreamReader in = new InputStreamReader((InputStream) conn.getContent());
        BufferedReader buff = new BufferedReader(in);
        String line;

        while (true) {
            if((line = buff.readLine()) != null){
                text.append(line);
            }else{
                break;
            }
        }
        return (text.toString());
    } catch (SocketTimeoutException socketTimeoutException) {
            throw new InternetConnectionUnavailableException();
    } catch (IOException ioException) {
            throw new InternetConnectionUnavailableException();
    }
}
</code></pre>

<p>However, it never gets in the "catch (SocketTimeoutException socketTimeoutException)" block. What's wrong here.</p>

<p>P.S. For the testing I've made a page that puts my server into sleep for 10 seconds.</p>
