« Return to Thread: Infinite loop when proxy credentials are wrong

Re: Infinite loop when proxy credentials are wrong

by olegk :: Rate this Message:

Reply to Author | View in Thread

lmenaria wrote:

> 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


This is not unexpected. Please see the javadoc of the
CredentialsProvider interface.

http://hc.apache.org/httpclient-3.x/apidocs/org/apache/commons/httpclient/auth/CredentialsProvider.html

I strongly recommend to avoid using CredentialsProvider in HttpClient 3.x

Oleg

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

 « Return to Thread: Infinite loop when proxy credentials are wrong