Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 365828 - Use IP address instead of DNS name for client address
Summary: Use IP address instead of DNS name for client address
Status: RESOLVED FIXED
Alias: None
Product: Jetty
Classification: RT
Component: client (show other bugs)
Version: 7.6.0.RC0   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 7.6.x   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-07 01:53 EST by Jan Bartel CLA
Modified: 2012-01-30 22:49 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Bartel CLA 2011-12-07 01:53:54 EST
I found a issue about HttpClient, as we know, before each HttpExchange
be sent, it will associate with an idle HttpConnection first, this
associate function is simple like this:

void associate(AbstractHttpConnection connection)
   {
       if (connection.getEndPoint().getLocalHost()!= null)
           _localAddress = new
Address(connection.getEndPoint().getLocalHost(),connection.getEndPoint().getLocalPort());
       _connection = connection;
       if (getStatus() == STATUS_CANCELLING)
           abort();
   }

But in one of my online service, one day, i found that It cost me
about 50 ~ 200 ms to connect to other http service if i use Jetty
HttpClient, it is unnormal, usually, it cost only 1 - 2 ms. So,
problem comes, at last, i found this associate function make this
happen.

"connection.getEndPoint().getLocalHost()" cost usually 50 ~ 200 ms, it
use function getCanonicalHostName() of Java InetAddress class. In some
cases, this function will go through DNS server to get the host name,
so its time taken is very long.

As this associate function was invoked before each http package sent
(In Jetty 7.4, this function was invoked twice one we sent a http
package), it is very important and we should keep its time taken is
short. So, why don't we  change

connection.getEndPoint().getLocalHost()

to

connection.getEndPoint().getLocalAddr()

It will works well, and will prevent this kind of problems. I do not
know whether it is a bug, but i hope you guys can fix it, thank you.
Comment 1 Greg Wilkins CLA 2012-01-30 22:49:30 EST
fixed