Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


DNS::hostByAddress can be slow #68

karlr42 opened this Issue · 5 comments

3 participants


I've found that for some domains, resolving takes on the order of 5 seconds in my environment. This is evident using HTTPSClientSession and I've put together a minimal test case here:

From my testing it looks like the issue is IPv6 related and is down to the AI_ADDRCONFIG flag passed to the getaddrinfo system call by DNS::hostByAddress. If I remove that flag and recompile the library(I'm using 1.4.6 downloaded from the main site) and then try my test case, resolution takes the normal(<1 sec) amount of time. I have also replicated the problem and made a small test case using just C and directly calling getaddrinfo. :

My setup is:
Ubuntu 12.10 64-bit
Configured Poco(1.4.6) with --no-tests --no-samples --omit=Data/OBDC,Data/MySQL
My ifconfig is : and the interface connected to the outside world is eth1.

I think the issue is down to the fact the domain in question has no AAAA records but my local machine has an assigned IPv6 address. So getaddrinfo, following the AI_ADDRCONFIG flag, makes a request an AAAA record, which timesout, and then makes a request for an A record, thus causing the delay. Or there is some other peculiarity with the DNS records for this site and others I've tried(, for example), I'm not sure.

So maybe this isn't necessarily a bug on your side, but I thought I would bring it to your attention anyway- this issue doesn't seem to affect any other application I use in this environment. I have patched Net::DNS::hostByAddress locally for now to remove the AI_ADDRCONFIG flag and my application(a proxy server making lots of DNS requests) is a lot faster now.


Maybe expose it in hostByName() and hostByAddress(), with default AI_CANONNAME | AI_ADDRCONFIG ?

On another note, FYI apparently something has changed in appinf DNS and test fails now. Not a big deal, just little bit annoying.


apparently something has changed in appinf DNS and test fails now

There was 1 failure: 
 1: N7CppUnit10TestCallerI7DNSTestEE.testHostByName
    " == "" || == """
    in "src/DNSTest.cpp", line 64
@aleks-f aleks-f was assigned
@aleks-f aleks-f referenced this issue from a commit
@aleks-f aleks-f GH #68: DNS::hostByAddress can be slow
GH #68: DNS::hostByAddress can be slow - added parameters in the
interface to pass hint flags to hostByAddress() and hostByName() calls

I could not reproduce this problem with my DNS, Windows 8, VS 2012. Flags can now be passed by user, if not explicitly passed, defaulting to AI_CANONNAME | AI_ADDRCONFIG. Will be in 1.5.2

@aleks-f aleks-f closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.