Bill Kelly | 2 May 21:04

Re: TCPSocket with multiple sub-domains - always a 60 second timeout


From: "Luke Bayes" <lbayes <at> patternpark.com>
>
> The official feed URL that we're hitting is:
> http://www.ndbc.noaa.gov/rss/ndbc_obs_search.php?lat=45.13N&lon=150.47W
> 
> Note the 'www.ndbc' sub-domain.
> 
> If we remove the 'www' portion, requests return in under a second (as
> expected), but if we leave that sub-domain in place, the request takes
> exactly 60 seconds, then returns with a valid result. If we insert
> additional sub-domains, we are delayed exactly 60 seconds for each
> sub-domain inserted and finally, the request will fail.

Hmm... on my system, I'm not getting any delays... All these 
responses returned in under a second:

$ ruby -v
ruby 1.8.6 (2007-11-18 patchlevel 5000) [x86_64-linux]

$ irb --simple-prompt
>> require 'socket'
=> false
>> s = TCPSocket.open("www.ndbc.noaa.gov", 80) ; s.close
=> nil
>> s = TCPSocket.open("ndbc.noaa.gov", 80) ; s.close
=> nil
>> s = TCPSocket.open("foo.ndbc.noaa.gov", 80) ; s.close
SocketError: getaddrinfo: Name or service not known
        from (irb):4:in `initialize'
        from (irb):4:in `open'
        from (irb):4

Same on Windows:

ruby 1.8.4 (2005-12-24) [i386-mswin32]

>> s = TCPSocket.open("www.ndbc.noaa.gov", 80) ; s.close
=> nil
>> s = TCPSocket.open("ndbc.noaa.gov", 80) ; s.close
=> nil
>> s = TCPSocket.open("www.ndbc.noaa.gov", 80) ; s.close
=> nil
>> s = TCPSocket.open("foo.ndbc.noaa.gov", 80) ; s.close
SocketError: getaddrinfo: no address associated with hostname.
        from (irb):6:in `initialize'
        from (irb):6

However, you might try:

Socket.do_not_reverse_lookup = true

...in case it makes any difference?

Regards,

Bill


Gmane