explicitly set a timeout for connecting and reading for a key server query

This commit is contained in:
Thialfihar 2010-08-18 00:53:18 +00:00
parent 18de5178f8
commit 08305b4963

View File

@ -87,6 +87,8 @@ public class HkpKeyServer extends KeyServer {
String url = "http://" + ips[i].getHostAddress() + ":" + mPort + request;
URL realUrl = new URL(url);
HttpURLConnection conn = (HttpURLConnection) realUrl.openConnection();
conn.setConnectTimeout(5000);
conn.setReadTimeout(25000);
conn.connect();
int response = conn.getResponseCode();
if (response >= 200 && response < 300) {