commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eric Renouf <eren...@skaion.com>
Subject Re: httpclient local address trouble
Date Tue, 07 Dec 2004 17:45:28 GMT
Ok, thanks for taking the time to look.  Here's a few pieces of my code:

This is from the constructor for the class:
        hostConf = new HostConfiguration();
        hostConf.setHost(cur);
        if(ip != null) {
            try {
                hostConf.setLocalAddress(InetAddress.getByName(ip));
            } catch(Exception e) {
                System.err.println("Couldn't get that address: " + e.getMessage());
            }
        }
        MultiThreadedHttpConnectionManager manager = new
MultiThreadedHttpConnectionManager();
        HttpConnectionManagerParams p = manager.getParams();
        p.setDefaultMaxConnectionsPerHost(100); // TODO Should be configurable
from file
        p.setMaxTotalConnections(100); // TOOD Should be configurable from file
        p.setConnectionTimeout(5000); // TODO should be configurable from file
        manager.setParams(p);
        manager.closeIdleConnections(5000); // TODO should be configurable from file
        browser = new HttpClient(manager);
        browser.setHostConfiguration(hostConf);


And this is where I try to actually do the request:

        GetMethod m = new GetMethod();
        try {
            m.setPath(cur.getPath());
            try {
                browser.executeMethod(hostConf, m);
                if(m.getStatusCode() != 200) {
                    warn("Got Status code " + String.valueOf(m.getStatusCode())
+ " for " + cur);
                    throw new NoPageException();
                }
                host = hostConf.getHostURL();
                links = getLinks(m);
            } catch(HttpException hEx) {
                System.out.println("Http Exception: " + hEx.getMessage());
            } catch(IOException ioEx) {
                System.out.println("IOException while browsing: " +
ioEx.getMessage());
            } finally {
                m.releaseConnection();
            }

I'm attaching the wire log, or at least the first few hundred lines from it.  If
I trimmed something you need to see let me know.  Thanks for your time and help.

Eric

Quoting Michael Becke <becke@u.washington.edu>:

> Hi Eric,
> 
> I can't think of anything at the moment that would cause this.  If you 
> post a sample of the code you are using and a wire log showing the 
> problem we should be able to track down the problem.
> 
> <http://jakarta.apache.org/commons/httpclient/3.0/logging.html>
> 
> Mike
> 
> On Dec 6, 2004, at 7:43 PM, Eric Renouf wrote:
> 
> > Hi,
> >
> > I'm trying to setup an application that will run a bunch of 
> > HttpClient's from
> > the same machine, simulating a bunch of different "real" users.  One 
> > thing that
> > would make the more real is to have them coming from different IP 
> > addresses,
> > which are all aliased on the machine already.  I tried creating an
> > HostConfiguration object and calling
> > hostConf.setLocalAddress(InetAddress.getByName(ip)); for each IP.  
> > Sometimes
> > this seems to work, but sometimes not.  When I watch the Apache logs 
> > I'll
> > sometimes see the IPs that I'm trying to use but more often than not I 
> > see the
> > default address for the host.  The line above does not raise an 
> > exception, and
> > if I call hostConf.getLocalAddress later it gives me the IP back (with 
> > a / in
> > front of it).
> >
> > I try both calling the setHostConfiguration on the HttpClient object 
> > and also
> > passing it in when I call executeMethod (GetMethod only being used).  
> > I'm using
> > the commons-httpclient-3.0-beta1 package.
> >
> > Can someone help point me in the direction for what I can do to figure 
> > out what
> > I'm doing wrong here?  I've tried googling "httpclient local address" 
> > and tried
> > similar searches through the mailing list archives but haven't found 
> > anything
> > too promising yet.  Any help would be very much appreciated.
> >
> > Eric
> > ___________________________________________________________
> > This mail sent using ToadMail -- Web based e-mail @ ToadNet
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: commons-user-help@jakarta.apache.org
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 



___________________________________________________________
This mail sent using ToadMail -- Web based e-mail @ ToadNet


Mime
View raw message