cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
86
Views
0
Helpful
0
Comments
cdnadmin
Community Member
This document was generated from CDN thread

Created by: Raymond Lynn on 20-01-2011 01:02:14 PM
I've written a custom Action Element in Java that makes an HTTP request and I need to read the data that is returned. It works fine when the web server is available but if it is not it take 21 seconds to timeout. I have tried to modify the timeout in the Java using the code below but nothing seems to work. Any ideas?
 
        HttpParams httpParameters = new BasicHttpParams();
//         Set the timeout in milliseconds until a connection is established.
        HttpConnectionParams.setConnectionTimeout(httpParameters, 300);
//         Set the default socket timeout (SO_TIMEOUT)
//         in milliseconds which is the timeout for waiting for data.
        HttpConnectionParams.setSoTimeout(httpParameters, 300);
 
 
 
 

Subject: RE: HTTP Timeout in Custom Action
Replied by: Joshua Dick on 27-01-2011 01:44:32 PM
Raymond,

It is correct to set both timeouts as you're doing.

How are you using your httpParameters object/where is it getting passed? I was able to use HttpParams from a DefaultHttpClient and the timeout works as expected when using httpcomponents-client-4.0.3:

HttpClient httpclient = new DefaultHttpClient();
HttpParams httpParams = httpclient.getParams();
HttpConnectionParams.setConnectionTimeout(httpParams, 300);
HttpConnectionParams.setSoTimeout(httpParams, 300);

try {
    HttpGet httpget = new HttpGet("http://1.2.3.4/");
    ....
    ....

Regards,

Josh

Subject: RE: HTTP Timeout in Custom Action
Replied by: Raymond Lynn on 31-01-2011 11:28:25 AM
Josh,
 
Here is how the http parameters are being used
 
        HttpClient httpclient = new DefaultHttpClient(httpParameters);
       
        HttpGet httpget = new HttpGet("http://10.34.32.16/");
        String surveyID = "";
        try {
             HttpResponse response = httpclient.execute( httpget );
             if (response.getStatusLine().getStatusCode() == 200) {
 
             etc
 
Best Regards
 
Boyd (AKA Raymond)

Subject: RE: HTTP Timeout in Custom Action
Replied by: Feroz Syed on 08-02-2011 06:10:29 AM
Raymond,

Apart from your http timeout settings, make sure that you set http timeout less than the fetchtimeout value. And also I believe you can set the http read timeout (httpsConnection.setReadTimeout(int timeout)) to have complete control over connecting and reading the http response.

Regards,
Feroz
Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Quick Links