Welcome Guest | Login

SocketError (getaddrinfo: Temporary failure in name resolution):

I'm trying to download an image from a url, save it, and resize it.

I'm using the code from here: http://snippets.dzone.com/user/seancribbs

In my controller action I then do this:

 file = UrlUpload.new(params[:url])

It works fine on my local machine when testing.  When this action runs on the hostingrails server, I get the following error:

 Parameters: {"commit"=>"Import", "url"=>"http://www.weddingthailand.com/images/wedding-thailand.jpg", "album_id"=>"561", "action"=>"url_import", "controller"=>"photo_import"}


SocketError (getaddrinfo: Temporary failure in name resolution):
   /usr/local/lib/ruby/1.8/net/http.rb:560:in `initialize'
   /usr/local/lib/ruby/1.8/net/http.rb:560:in `open'
   /usr/local/lib/ruby/1.8/net/http.rb:560:in `connect'
   /usr/local/lib/ruby/1.8/timeout.rb:48:in `timeout'
   /usr/local/lib/ruby/1.8/timeout.rb:76:in `timeout'
   /usr/local/lib/ruby/1.8/net/http.rb:560:in `connect'
   /usr/local/lib/ruby/1.8/net/http.rb:553:in `do_start'
   /usr/local/lib/ruby/1.8/net/http.rb:542:in `start'
   /usr/local/lib/ruby/1.8/open-uri.rb:242:in `open_http'
   /usr/local/lib/ruby/1.8/open-uri.rb:626:in `buffer_open'
   /usr/local/lib/ruby/1.8/open-uri.rb:164:in `open_loop'
   /usr/local/lib/ruby/1.8/open-uri.rb:162:in `catch'
   /usr/local/lib/ruby/1.8/open-uri.rb:162:in `open_loop'
   /usr/local/lib/ruby/1.8/open-uri.rb:132:in `open_uri'
   /usr/local/lib/ruby/1.8/open-uri.rb:528:in `open'
   /usr/local/lib/ruby/1.8/open-uri.rb:30:in `open'
   /app/controllers/photo_import_controller.rb:24:in `initialize'
   /app/controllers/photo_import_controller.rb:62:in `new'
   /app/controllers/photo_import_controller.rb:62:in `url_import'

Any ideas?

2007-08-24 07:51 AM

Hmm - yeah - Google doesn't seem to be much help on that error.  'just a bunch of people on the ruby mailing list yelling at each other.

Can you do something like this
require 'net/http'
http = Net::HTTP.new("www.weddingthailand.com", 80)
path = "/images/wedding-thailand.jpg"

headers = {
'User-Agent' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.12) Gecko/20050915 Firefox/2.0.0.6',
'Accept' => 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5',
'Accept-Encoding'=> 'gzip,deflate',
'Accept-Charset'=> 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
'Keep-Alive'=> '100000',
'Connection'=> 'keep-alive',
'Cache-Control'=> 'max-age=0'}

resp, data = http.post(path, data, headers)
will it connect OK ?  

What version of Ruby are you running locally?  Is the code compatible with Ruby 1.8.6?

2007-08-24 06:19 PM

Thanks for the reply.  Yeah - I'm running Ruby 1.8.6 locally (on windows):
ruby 1.8.6 (2007-03-13 patchlevel 0) [i386-mswin32]

I'll try those changes you suggest and let you know.

2007-08-25 08:47 PM

hmm.  Actually - I was about to start testing the code you suggested, but before I did I thought I'd try the existing code, and now it's working just fine....  Odd....

Thanks for your help anyway!

2007-08-25 08:58 PM


Hello Guest! In order to post you must be an active client with us, please log in or sign up today!