Luke Bayes | 2 May 20:10

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

Hey Folks,

We've stumbled over a surprising behavior and I wanted to check in to
see if anyone else has experienced this.

We're trying to download and parse RSS feeds. The URL that we're
hitting has two sub-domains (Is that even valid http?)

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.

We've chased the blocking line to line 574 of net/http.rb

def connect
  D "opening connection to #{conn_address()}..."
  s = timeout(@open_timeout) { TCPSocket.open(conn_address(), conn_port()) }
  D "opened"
...

The behavior is still exhibited when this code is changed to:

def connect
  puts "opening connection to #{conn_address()}..."
  s = TCPSocket.open(conn_address(), conn_port())
  puts "opened"
...

It seems the TCPSocket code is written in C and that's where my
ability to track issues pretty much stops.

Is this a known issue? Is there a workaround? Can anyone else
reproduce with the following code:

----------------------8<-----------------------

require 'open-uri'

# The following URL times out at 60 seconds and then works
url = "http://www.ndbc.noaa.gov/rss/ndbc_obs_search.php?lat=45.13N&lon=150.47W"
# The following URL times out at 120 seconds and then fails
url = "http://www.www.ndbc.noaa.gov/rss/ndbc_obs_search.php?lat=45.13N&lon=150.47W"
# The following URL works fine:
#url = "http://ndbc.noaa.gov/rss/ndbc_obs_search.php?lat=45.13N&lon=150.47W"

puts "request: #{url}"
result = open(url).read
puts "result: #{result}"

---------------------->8-----------------------

Both Firefox and Safari will load both valid URLs within a second or two.

Here is my Ruby version:
ruby 1.8.6 (2007-09-24 patchlevel 111) [universal-darwin9.0]

I'm on OS X 10.5.2

Any help would be grealy appreciated!

Thanks,

Luke Bayes


Gmane