Instead of fighting with a separate observer stream, it may be enough for you (although this is not quite an answer to your requirement) if you enable connection and read timeouts in a network connection, for example:
URL url = new URL("...");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setConnectTimeout(5000);
conn.setReadTimeout(10000);
InputStream is = conn.getInputStream();
, 5 (5000 ), 10 (10000 ) , . , .