hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lmenaria <menarialaxmi...@gmail.com>
Subject Infinite loop when proxy credentials are wrong
Date Tue, 02 Jun 2009 12:32:06 GMT

Hello everyone, 

I have created a sample application which connect to site with GetMethod,
its working fine. Its also working fine when I tried with proxy, But when I
provided wrong proxy credentials then it hangs.

Have tried with enabled info logging and got it goes in infinite loop. there
are too many below statements.

2009-06-02 17:38:34,343 [AWT-EventQueue-0] INFO 
org.apache.commons.httpclient.auth.AuthChallengeProcessor - basic
authentication scheme selected
2009-06-02 17:38:34,343 [AWT-EventQueue-0] INFO 
org.apache.commons.httpclient.auth.AuthChallengeProcessor - basic
authentication scheme selected
2009-06-02 17:38:34,359 [AWT-EventQueue-0] INFO 
org.apache.commons.httpclient.auth.AuthChallengeProcessor - basic
authentication scheme selected
2009-06-02 17:38:34,359 [AWT-EventQueue-0] INFO 
org.apache.commons.httpclient.auth.AuthChallengeProcessor - basic
authentication scheme selected
2009-06-02 17:38:34,359 [AWT-EventQueue-0] INFO 
org.apache.commons.httpclient.auth.AuthChallengeProcessor - basic
authentication scheme selected
2009-06-02 17:38:34,375 [AWT-EventQueue-0] INFO 
org.apache.commons.httpclient.auth.AuthChallengeProcessor - basic
authentication scheme selected
2009-06-02 17:38:34,375 [AWT-EventQueue-0] INFO 
org.apache.commons.httpclient.auth.AuthChallengeProcessor - basic
authentication scheme selected
2009-06-02 17:38:34,375 [AWT-EventQueue-0] INFO 
org.apache.commons.httpclient.auth.AuthChallengeProcessor - basic
authentication scheme selected
2009-06-02 17:38:34,390 [AWT-EventQueue-0] INFO 
org.apache.commons.httpclient.auth.AuthChallengeProcessor - basic
authentication scheme selected
2009-06-02 17:38:34,390 [AWT-EventQueue-0] INFO 
org.apache.commons.httpclient.auth.AuthChallengeProcessor - basic
authentication scheme selected
2009-06-02 17:38:34,390 [AWT-EventQueue-0] INFO 
org.apache.commons.httpclient.auth.AuthChallengeProcessor - basic
authentication scheme selected
2009-06-02 17:38:34,390 [AWT-EventQueue-0] INFO 
org.apache.commons.httpclient.auth.AuthChallengeProcessor - basic
authentication scheme selected
2009-06-02 17:38:34,406 [AWT-EventQueue-0] INFO 
org.apache.commons.httpclient.auth.AuthChallengeProcessor - basic
authentication scheme selected
2009-06-02 17:38:34,406 [AWT-EventQueue-0] INFO 
org.apache.commons.httpclient.auth.AuthChallengeProcessor - basic
authentication scheme selected

Please let me know what is the issue ?

I'm using httpclient3.1.

My Sample code is:

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package testjava;

import java.io.IOException;
import net.chambal.license.ProxyAuthentication;
import org.apache.commons.httpclient.HostConfiguration;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
import org.apache.commons.httpclient.auth.CredentialsProvider;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.params.HttpConnectionManagerParams;

/**
 *
 * @author Administrator
 */
public class LM {

    private MultiThreadedHttpConnectionManager connectionManager = null;

    public static void main(String[] args) {
        LM oo = new LM();
        oo.ss();
        for (int i = 0; i <= 4; i++) {
            oo.check();
        }
    }

    private void ss() {
        HttpConnectionManagerParams connectionParams = new
HttpConnectionManagerParams();
        connectionParams.setConnectionTimeout(6000);
        connectionParams.setSoTimeout(6000);
        connectionParams.setTcpNoDelay(true);

        connectionManager = new MultiThreadedHttpConnectionManager();
        connectionManager.setParams(connectionParams);

    }

    private void check() {
        GetMethod method = null;
        try {

            String sAutoDetect = "false";
            String proxy = "192.168.0.98 ";
            String port = "3128";
            String user = "aa";
            String pass = "aa";
            String sDomain = "aa";

            HttpClient httpClient = new HttpClient(connectionManager);

            HostConfiguration secureHostConfig = new HostConfiguration();
            secureHostConfig.setHost("example.com", 443, "https");
            httpClient.setHostConfiguration(secureHostConfig);

            if (sAutoDetect.equalsIgnoreCase("true") == true) {
                proxy = "";
                port = "";
            }

            if (proxy != null && proxy.equalsIgnoreCase("") == false && port
!= null && port.equalsIgnoreCase("") == false) {
                secureHostConfig.setProxy(proxy, Integer.parseInt(port));
                if (user != null && pass != null && sDomain != null) {
                    if (user.equalsIgnoreCase("") == false &&
pass.equalsIgnoreCase("") == false) {
                        ProxyAuthentication objProxyAuthentication = null;
                        objProxyAuthentication = new
ProxyAuthentication(user, pass, sDomain, proxy);
                       
httpClient.getParams().setParameter(CredentialsProvider.PROVIDER,
objProxyAuthentication);
                       
httpClient.getParams().setAuthenticationPreemptive(false);
                    }
                }
            }

            method = new GetMethod("https://example.com");
            int statusCode = 0;
            statusCode = httpClient.executeMethod(secureHostConfig, method);
            method.releaseConnection();

            connectionManager.closeIdleConnections(0);

        } catch (Exception e) {

            System.out.print(e.getStackTrace().toString());

        }
    }
}


Thanks in advance.
Laxmilal
-- 
View this message in context: http://www.nabble.com/Infinite-loop-when-proxy-credentials-are-wrong-tp23831651p23831651.html
Sent from the HttpClient-User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Mime
View raw message