@@ -79,6 +79,9 @@ public final class AndroidHttpClient implements HttpClient {
7979 // Gzip of data shorter than this probably won't be worthwhile
8080 public static long DEFAULT_SYNC_MIN_GZIP_BYTES = 256 ;
8181
82+ // Default connection and socket timeout of 60 seconds. Tweak to taste.
83+ private static final int SOCKET_OPERATION_TIMEOUT = 60 * 1000 ;
84+
8285 private static final String TAG = "AndroidHttpClient" ;
8386
8487
@@ -107,9 +110,8 @@ public static AndroidHttpClient newInstance(String userAgent, Context context) {
107110 // and it's not worth it to pay the penalty of checking every time.
108111 HttpConnectionParams .setStaleCheckingEnabled (params , false );
109112
110- // Default connection and socket timeout of 20 seconds. Tweak to taste.
111- HttpConnectionParams .setConnectionTimeout (params , 20 * 1000 );
112- HttpConnectionParams .setSoTimeout (params , 20 * 1000 );
113+ HttpConnectionParams .setConnectionTimeout (params , SOCKET_OPERATION_TIMEOUT );
114+ HttpConnectionParams .setSoTimeout (params , SOCKET_OPERATION_TIMEOUT );
113115 HttpConnectionParams .setSocketBufferSize (params , 8192 );
114116
115117 // Don't handle redirects -- return them to the caller. Our code
@@ -125,7 +127,8 @@ public static AndroidHttpClient newInstance(String userAgent, Context context) {
125127 schemeRegistry .register (new Scheme ("http" ,
126128 PlainSocketFactory .getSocketFactory (), 80 ));
127129 schemeRegistry .register (new Scheme ("https" ,
128- SSLCertificateSocketFactory .getHttpSocketFactory (30 * 1000 , sessionCache ), 443 ));
130+ SSLCertificateSocketFactory .getHttpSocketFactory (
131+ SOCKET_OPERATION_TIMEOUT , sessionCache ), 443 ));
129132
130133 ClientConnectionManager manager =
131134 new ThreadSafeClientConnManager (params , schemeRegistry );
0 commit comments