Raghavan, I am not entirely sure I understood the problem. However, here's a few general recommendations:
(1) Upgrade to HttpClient 2.0.1. 2.0a3 had a nasty bug you want fixed. PR #26500 - Socket timeout is now correctly set on open connections http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26500 (2) Per default socket timeout is disabled. If you do not explicitly set SO_TIMEOUT value, your connection should never time out. (3) If you do need to set SO_TIMEOUT, you should not directly manipulate HttpConnection instances. HttpClient WILL OVERRIDE their properties per each method execution. Use HttpClient#setTimeout() method instead. Hope this helps Oleg On Tue, 2004-09-28 at 13:05, [EMAIL PROTECTED] wrote: > > > > Hi Everyone > > Iam Raghavan R, using the jakarta - commons - HttpClient utility viz, > commons-httpclient-2.0-rc3.jar, commons-logging.jar, > commons-logging-api.jar. > > In our project we have class which uses - HttpClient to create secure > connection. > > The question is 'Iam getting connection:timed out' exception all along > (if i dont use the bolded code to setSoTimeOut () param using > HttpConnection, HttpConnectionManager objects). > > If i use (code below), I get 'java.lang.IllegalStateException: a default > host must be set to create a host URL. > The output i got for SOP - is null for HOST. > > I dont know how can over come the Connection timed out exception or > IllegalStateException (here to set the HOST part). > > One of the property file is used to load the actual URL in a different > method - and that works fine - iam able to see the SOP of URL iam > connecting to. > > Another important thing is, the same code works in one of the other > machines. Both have the same setup and property files and property values. > > If anyone, does know how to set - SOTimeOut using setSOTimeOut () - please > do give that. > > The Code is given below for your info: > > ================================= CODE START > String response = null; > try > { > //PutMethod post = new PutMethod(url); > > PostMethod post = new PostMethod(url); > post.setRequestBody((input)); > > // Per default, the request content needs to be buffered > // in order to determine its length. > // Request body buffering can be avoided when > // = content length is explicitly specified > // = chunk-encoding is used > > if (input.length() < Integer.MAX_VALUE) > { > post.setRequestContentLength((int)input.length()); > } > else > { > post.setRequestContentLength(EntityEnclosingMethod.CONTENT_LENGTH_CHUNKED); > } > > // Specify content type and encoding > // If content encoding is not explicitly specified > // ISO-8859-1 is assumed > > //System.out.println("commented the content type text/xml"); > > post.setRequestHeader("Content-type", "text/xml; charset=ISO-8859-1"); > // Get HTTP client > > HttpClient httpclient = new HttpClient(); > > /* ******************* > // This is a part of code that we used for accessing Sungard QA environment > // when Sungard did not ahve a valid certificate in QA. > // <GL> 09/26/04 > if (trustSungardServer) > { > httpclient.setStrictMode(false); > } > ********************** */ > > // Execute request > > long start = System.currentTimeMillis(); > HostConfiguration hostConfiguration = httpclient.getHostConfiguration (); > System.out.println( ">>> Host ===============" + hostConfiguration.getHost > () ); > System.out.println( ">>> HostURL ============" + > hostConfiguration.getHostURL () ); > System.out.println(">>> PORT ==============" + hostConfiguration.getPort() > ); > System.out.println(">>> PROTOCOL ==========" + > hostConfiguration.getProtocol() ) ; > > HttpConnectionManager httpConnectionManager = > httpclient.getHttpConnectionManager() ; > HttpConnection httpConnection= > httpConnectionManager.getConnection(hostConfiguration); > > httpConnection.setSoTimeout(50000); > > > int result = httpclient.executeMethod(post); > > long end = System.currentTimeMillis(); > System.out.println("total time is " + (end-start) + "millis"); > System.out.println("total time is " + ((end-start)/1000) + "secs"); > > > // Display response > System.out.println("Response body: "); > response = post.getResponseBodyAsString(); > Header [] responseHeaders = post.getResponseHeaders(); > =================================================================== END > CODE > > > Thanks & Regards, > Raghavan Rangarajan > > Location: 11C123 > PSTN: +91 44 2254 6000 Extn:2703 > Office e-mail-id: [EMAIL PROTECTED] > iNautix Technologies India Private Limited > > > --------------------------------------------------------------------- > 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]