Wire log would definitely help. Have you tried executing your code
against a valid URL? Besides, you might also want to examine proxy &
target HTTP server logs. It would be very helpful to know where exactly
the connection gets dropped.

Cheers

Oleg


Well, this one should be an easy one. Status code 404 is returned in
case the target URL cannot be found. Please double-check your target URL

> PostMethod method = new PostMethod(aURL);
                                    ^^^^^^

On Thu, 2003-07-10 at 21:32, Ramanan nr wrote:
> Hi Mike, Oleg
> 
> Thanks for the response.
> 
> Though I have the latest build, I am still getting the
> socket closed exception. 
> 
> I guess I am missing something in the funda.
> 
> Here is my code:
> 
> 
>               
>       // SET SYS PROP FOR HTTPCLIENT DEBUG
>               System.setProperty("org.apache.commons.logging.Log",
> "org.apache.commons.logging.impl.SimpleLog"); 
>       
> System.setProperty("org.apache.commons.logging.simplelog.showdatetime",
> "true"); 
>       
> System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire",
> "debug"); 
>       
> System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient",
> "debug"); 
>               
>               
>               //the following decleration can be changed to
> HttpMethodBase
>               aHttpClient = new HttpClient();
>               PostMethod method = new PostMethod(aURL);
>               method.setFollowRedirects(true);
>               method.setStrictMode(false);
>               method.setRequestBody(aRequest);
>               method.setRequestHeader("Content-type",
> "application/x-www-form-urlencoded");         
>       
> method.setRequestContentLength(PostMethod.CONTENT_LENGTH_AUTO);
>               //method.setRequestContentLength(aRequest.length());
>               
>               int aStatusCode = -1;
>               String aResponse = null;
>               try {
> 
>               aHttpClient.getState().setProxyCredentials(
>                               null,
>                               null,
>                               new UsernamePasswordCredentials(ProxyUID,
> ProxyPwd));
> 
>                       HostConfiguration aHConfig = new
> HostConfiguration();
>                       aHConfig.setHost(aHost,aPort,aProtocol);
>                       aHConfig.setProxy(aProxyHost, aProxyPort);
>                       method.setHostConfiguration(aHConfig);
>                       
>                       aHttpClient.setConnectionTimeout(10000);
>                       //aHttpClient.setTimeout(10000);
> 
>                       // BEGIN RETRY CODE
> 
>                       int attempt = 0;
>                       Exception retriedException = null;
>                       // We will retry up to 3 times.
>                       while (aStatusCode == -1 && attempt < 3) {
>                               try {
>                                       
>                                       attempt++;
>                               
> aHttpClient.getHttpConnectionManager().getConnection(aHConfig).setSoTimeout(10000);
>                       
>                                       aStatusCode = 
> aHttpClient.executeMethod(method);
> 
>                                       //if successful come off the loop
>                                       
>                               } catch (HttpRecoverableException e) {
>                                       retriedException = e;
>                                       if (log.isDebugEnabled()) {
>                                               log.debug("A recoverable exception 
> occurred,
> retrying.", e);
>                                               log.debug("Status code from 
> executMethod = " +
> aStatusCode);
>                                       }
> 
>                               } catch (HttpException he) {
>                               
>                                       //throw something
>                                       
>                               } catch (IOException e) {
> 
>                                       //throw something                              
>          
> 
>                               }
>                       }//end while
>                       // Check that we didn't run out of retries.
>                       if (aStatusCode == -1) {
>                               log.debug("Failed to recover from exception.");
>                               //throw something
>                       }
> 
>                       // Check that we didn't get a status other than OK
> (200).
>                       if (aStatusCode != HttpStatus.SC_OK) {
>                               log.debug("Bad status code from executMethod = " +
> aStatusCode);
>                               //throw something
>                       }
> 
> 
> 
>               //Get a handle to the input stream returned by the
> server.       
>               //BufferedInputStream rspStream = new
> BufferedInputStream( method.getResponseBodyAsStream()
> );
> 
>               String strResponse = null;
> 
>               StringBuffer strBuffer = new StringBuffer();
> 
>               BufferedReader reader = null;
> 
>               try {
> 
>                       //Get a handle to the input stream returned by the
> server.       
>                       InputStream inStream =
> aMethod.getResponseBodyAsStream();
>                       reader = new BufferedReader(new
> InputStreamReader(inStream));
>                       String line = null;
>                       int letter = 0;
>                       while ((letter = reader.read()) != -1)
>                               strBuffer.append((char) letter);
>                       inStream.close();
>               } catch (Exception e) {
>                       //create exception
>               } finally {
>                       if (exceptionToThrow != null) {
>                               //throw exception
>                       }
>               } //end finally
>               return strBuffer.toString();
> 
>       
> 
> The request I send to the Postmethod is an XML
> request.
> 
> the url is : https://....
> 
> 
> I tried the same code with http and it works fine (as
> expected I am getting a 404 from the server).
> 
> 
> any light.. will be helpful.
> 
> -
> NRR
> 
> 
> 
> 
> --- Michael Becke <[EMAIL PROTECTED]> wrote:
> > The patch for 20938 should have been included in
> > beta 2.
> > 
> > Mike
> > 
> > Oleg Kalnichevski wrote:
> > > I am a bit doubtful that the bug fix #20938 had
> > anything to do with your
> > > problem. Anyway, it can get the most recent
> > nightly build at the
> > > following location
> > > 
> > >
> >
> http://cvs.apache.org/builds/jakarta-commons/nightly/commons-httpclient/
> > > 
> > > If the problem persists after upgrade, please
> > refer to the
> > > trouble-shooting guide for instructions
> > > 
> > >
> >
> http://jakarta.apache.org/commons/httpclient/troubleshooting.html
> > > 
> > > Cheers
> > > 
> > > Oleg
> > > 
> > > 
> > > On Thu, 2003-07-10 at 20:10, Ramanan nr wrote:
> > > 
> > >>Hello,
> > >>
> > >>I am using the latest (downloaded early this week)
> > >>commons-httpclient-2.0-beta2.jar
> > >>
> > >>Works fine with http.
> > >>
> > >>I am trying to make a https connection thru a
> > proxy.
> > >>I am getting the following exception:
> > >>
> > >>java.net.SocketException: Socket closed
> > >>  at
> > java.net.PlainSocketImpl.socketGetOption(Native
> > >>Method)
> > >>  at
> >
> >>java.net.PlainSocketImpl.getOption(PlainSocketImpl.java:214)
> > >>  at
> > java.net.Socket.getSendBufferSize(Socket.java:548)
> > >>  at
> >
> >>org.apache.commons.httpclient.HttpConnection.tunnelCreated(HttpConnection.java:756)
> > >>  at
> >
> >>org.apache.commons.httpclient.ConnectMethod.execute(ConnectMethod.java:204)
> > >>  at
> >
> >>org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:638)
> > >>  at
> >
> >>org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:500)
> > >>
> > >>Looks like this was addressed as Bug 20938 and got
> > >>fixed (changes to HttpMethodBase.java)
> > >>
> > >>How do I get to the binary version of the patch? 
> > >>I don't have the environment to compile the
> > httpclient
> > >>src.
> > >>
> > >>Thanks in advance
> > >>NRR
> > >>
> > >>__________________________________
> > >>Do you Yahoo!?
> > >>SBC Yahoo! DSL - Now only $29.95 per month!
> > >>http://sbc.yahoo.com
> > >>
> >
> >>---------------------------------------------------------------------
> > >>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]
> > > 
> > 
> > 
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> >
> [EMAIL PROTECTED]
> > For additional commands, e-mail:
> > [EMAIL PROTECTED]
> > 
> 
> 
> __________________________________
> Do you Yahoo!?
> SBC Yahoo! DSL - Now only $29.95 per month!
> http://sbc.yahoo.com
> 
> ---------------------------------------------------------------------
> 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]

Reply via email to