aboutsummaryrefslogtreecommitdiff
path: root/subsonic-android/src
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2012-07-07 12:55:55 -0700
committerScott Jackson <daneren2005@gmail.com>2012-07-07 12:55:55 -0700
commit858e7f513c6ecf2e575b6fd6120f6effbef09420 (patch)
tree39000e0f69ce987ca2f51bf28eb99602b2ef6bd9 /subsonic-android/src
parent3e560496b7951cda1724fa2580ee0601dbe5b88c (diff)
downloaddsub-858e7f513c6ecf2e575b6fd6120f6effbef09420.tar.gz
dsub-858e7f513c6ecf2e575b6fd6120f6effbef09420.tar.bz2
dsub-858e7f513c6ecf2e575b6fd6120f6effbef09420.zip
Better Network Timeout implementation
Diffstat (limited to 'subsonic-android/src')
-rw-r--r--subsonic-android/src/github/daneren2005/subphonic/service/RESTMusicService.java10
1 files changed, 6 insertions, 4 deletions
diff --git a/subsonic-android/src/github/daneren2005/subphonic/service/RESTMusicService.java b/subsonic-android/src/github/daneren2005/subphonic/service/RESTMusicService.java
index b9da4c1a..133c165a 100644
--- a/subsonic-android/src/github/daneren2005/subphonic/service/RESTMusicService.java
+++ b/subsonic-android/src/github/daneren2005/subphonic/service/RESTMusicService.java
@@ -666,6 +666,12 @@ public class RESTMusicService implements MusicService {
List<String> parameterNames, List<Object> parameterValues,
List<Header> headers, ProgressListener progressListener, CancellableTask task) throws IOException {
Log.i(TAG, "Using URL " + url);
+
+ SharedPreferences prefs = Util.getPreferences(context);
+ int networkTimeout = Integer.parseInt(prefs.getString(Constants.PREFERENCES_KEY_NETWORK_TIMEOUT, "15000"));
+ HttpParams newParams = httpClient.getParams();
+ HttpConnectionParams.setSoTimeout(newParams, networkTimeout);
+ httpClient.setParams(newParams);
final AtomicReference<Boolean> cancelled = new AtomicReference<Boolean>(false);
int attempts = 0;
@@ -705,15 +711,11 @@ public class RESTMusicService implements MusicService {
}
// Set credentials to get through apache proxies that require authentication.
- SharedPreferences prefs = Util.getPreferences(context);
int instance = prefs.getInt(Constants.PREFERENCES_KEY_SERVER_INSTANCE, 1);
String username = prefs.getString(Constants.PREFERENCES_KEY_USERNAME + instance, null);
String password = prefs.getString(Constants.PREFERENCES_KEY_PASSWORD + instance, null);
httpClient.getCredentialsProvider().setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT),
new UsernamePasswordCredentials(username, password));
-
- int networkTimeout = Integer.parseInt(prefs.getString(Constants.PREFERENCES_KEY_NETWORK_TIMEOUT, "10000"));
- httpClient.getParams().setParameter("http.socket.timeout", networkTimeout);
try {
HttpResponse response = httpClient.execute(request, httpContext);