I have a simple piece of code that allows a user to specify a URL,
port, username, and password to grab a frame from a network camera.
An exception is thrown properly if the url can't be resolved, or if
the authentication fails.  However, I can't seem to throw an exception
in a reasonable amount of time if the server is available but the port
is closed (or the user entered the wrong port number).  It just seems
to sit and wait for a *long* time...

HttpParams params = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(params, netConnectTimeout);
HttpConnectionParams.setSoTimeout(params, netReadTimeout);
DefaultHttpClient httpclient = new DefaultHttpClient(params);
httpclient.setHttpRequestRetryHandler(new
DefaultHttpRequestRetryHandler(0, false));
UsernamePasswordCredentials credentials = new
UsernamePasswordCredentials(username + ":" + password);
httpclient.getCredentialsProvider().setCredentials(new AuthScope
(hostName,port),credentials);
HttpGet method = new HttpGet(cameraUrl);
HttpResponse response = httpclient.execute(method);

(netConnectTimeout & netReadTimeout are both set to 10000)

After doing a substantial amount of reading, I believe I understand
why netConnectTimeout and netReadTimeout have no effect on this
particular problem.  After discovering "HttpRequestRetryHandler" I
believed I had found the solution.  However after applying what I had
found to my code (line 5 above), it had no effect.  The connection
still sits and waits far longer than 10 seconds when the incorrect
port is specified in the prefs.

Can anybody help?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to