Timeout error--newbie needs help, please


#1

Hi,

I’m trying to interface with NewsGator’s API, which is a RESTful
interface. I’m using their sample code:

def loadLocations(username, password)
http = Net::HTTP.start(‘services.newsgator.com’)
req = Net::HTTP::Get.new(’/ngws/svc/Location.aspx’)
req[‘X-NGAPIToken’] = API_PRODUCT_KEY
req.basic_auth username,password
http.request(req) { |response| locationsLoaded(response) }
end

def locationsLoaded(response)
printf response
end

but when I execute this (with the username, password, and
API_PRODUCT_KEY set correctly), I get a printout of the locations
followed by a timeout error:

ml>
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/
1.8/timeout.rb:54:in rbuf_fill': execution expired (Timeout::Error) from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ ruby/1.8/timeout.rb:56:intimeout’
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/
ruby/1.8/timeout.rb:76:in timeout' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ ruby/1.8/net/protocol.rb:132:inrbuf_fill’
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/
ruby/1.8/net/protocol.rb:86:in read' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ ruby/1.8/net/http.rb:2221:inread_body_0’
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/
ruby/1.8/net/http.rb:2182:in read_body' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ ruby/1.8/net/http.rb:2207:inbody’
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/
ruby/1.8/net/http.rb:2146:in reading_body' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ ruby/1.8/net/http.rb:1061:inrequest’
from app.rb:14:in `loadLocations’
from app.rb

(app.rb is the name of my program at the moment)
Any code written after calling loadLocations is not executed.

Can anyone explain to me what mistake I’m making? Or at least tell me
“Stupid, go read <this_cool_ruby_webpage> and you’ll figure it out
yourself”

Thanks!