On Wed, 2007-08-15 at 17:56 +0300, Vitaly Baranovsky wrote:
> Good day!
>
> Connection timeouts of httpClient in my program doesn't works. I set
> timeout to 10 000 milliseconds, but my program waits for about 65
> seconds before answering.
...
> Here is the code of my class:
>
> public class HttpGetter {
>
> private static final int DEFAULT_SOCKET_TIMEOUT = 10000;
> private HttpClient httpClient;
> private GetMethod method;
>
> public HttpGetter() {
> super();
> MultiThreadedHttpConnectionManager cm = new
> MultiThreadedHttpConnectionManager();
> cm.getParams().setSoTimeout(DEFAULT_SOCKET_TIMEOUT);
>
Hi Vitaly,
On top of what Pete Keyes just said, in your code you are setting a
socket timeout, not a connect timeout. No wonder you are not getting the
expected result.
Oleg
> httpClient = new HttpClient(cm);
> }
>
> private String getFromURLAsString(String url) throws HttpException,
> IOException {
> URI uri = new URI(url, false);
> method = new GetMethod(uri.getEscapedURI());
> method.getParams().setSoTimeout(DEFAULT_SOCKET_TIMEOUT);
> int result = httpClient.executeMethod(method);
> return method.getResponseBodyAsString();;
> }
> }
>
>
>
> Here is the code of my TestCase:
>
> public class HttpGetterTest extends TestCase {
> public void testGetFromUrlAsString() throws HttpException, IOException{
> HttpGetter httpGetter = new HttpGetter();
>
> System.out.println(httpGetter.getFromURLAsString("http://google.com"));
> }
> }
>
>
> Why timeouts doesn't works?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]