SocketError - getaddrinfo: Name or service not known:
-
MJ
Is there any additional information I can supply to help?
- sinatra (0.3.3)
- thin (1.0.0)
- rack (0.4.0)
- eventmachine (0.12.2)
Any suggestions for other things to try?
I switched from RestClient to Curb (curl lib) and still have the same issue:
Curl::Err::HostResolutionError - Couldn't resolve host name:It seems like running this Sinatra app under Thin causes some issues resolving host names when making outbound requests.
I really want to use Thin because I can then monitor it's pid file with god to make sure the app stays up.
-
macournoyer
- Milestone changed from Future to 1.1
- State changed from new to open
You get this error when using RestClient to access another service or to hit the Thin server?. Can you provide more code to reproduce?
-
MJ
Currently I'm unable to get my Thin server running to reproduce the error.
I filed a ticket w/Sinatra however it's tagged as 'thin error'
http://sinatra.lighthouseapp.com...
I uploaded the code to a public git repo so anyone could give it a whirl: http://github.com/mjfreshyfresh/...
Currently I'm unable to start the Thin server, it appears to be starting correctly, then it starts again with each request.
The start command I'm using is:
thin -C ./config.ymlCould you grab my code and confirm that I'm doing this correctly.
The gems I'm using are: * thin (1.0.0) * rack (0.9.1) * sinatra (0.9.0.2)
The full stack trace is:
!! Unexpected error while processing request: undefined method `run' for main:Object undefined method `run' for main:Object /Users/mjfreshyfresh/projects/scg/face_mask/simple_app/config.ru:7 /usr/local/lib/ruby/gems/1.8/gems/sinatra-0.9.0.2/lib/sinatra/base.rb:812:in `load' /usr/local/lib/ruby/gems/1.8/gems/sinatra-0.9.0.2/lib/sinatra/base.rb:812:in `reload!' /usr/local/lib/ruby/gems/1.8/gems/sinatra-0.9.0.2/lib/sinatra/base.rb:804:in `call' /usr/local/lib/ruby/gems/1.8/gems/thin-1.0.0/lib/thin/connection.rb:63:in `pre_process' /usr/local/lib/ruby/gems/1.8/gems/thin-1.0.0/lib/thin/connection.rb:54:in `process' /usr/local/lib/ruby/gems/1.8/gems/thin-1.0.0/lib/thin/connection.rb:39:in `receive_data' /usr/local/lib/ruby/gems/1.8/gems/eventmachine-0.12.2/lib/eventmachine.rb:231:in `run_machine' /usr/local/lib/ruby/gems/1.8/gems/eventmachine-0.12.2/lib/eventmachine.rb:231:in `run' /usr/local/lib/ruby/gems/1.8/gems/thin-1.0.0/lib/thin/backends/base.rb:57:in `start' /usr/local/lib/ruby/gems/1.8/gems/thin-1.0.0/lib/thin/server.rb:150:in `start' /usr/local/lib/ruby/gems/1.8/gems/thin-1.0.0/lib/thin/controllers/controller.rb:80:in `start' /usr/local/lib/ruby/gems/1.8/gems/thin-1.0.0/lib/thin/runner.rb:173:in `send' /usr/local/lib/ruby/gems/1.8/gems/thin-1.0.0/lib/thin/runner.rb:173:in `run_command' /usr/local/lib/ruby/gems/1.8/gems/thin-1.0.0/lib/thin/runner.rb:139:in `run!' /usr/local/lib/ruby/gems/1.8/gems/thin-1.0.0/bin/thin:6 /usr/local/bin/thin:19:in `load' /usr/local/bin/thin:19 -
macournoyer
It seems to be a problem w/ how Sinatra reloads the config file.
It doesn't work w/ rackup either:
rackup config.rusame error, which uses mongrel.
-
MJ
Problem solved need to include a line to 'disable :reload'
Thanks to atduskgreg and Blake for the support.
require 'rubygems' require 'sinatra' require 'rest_client' set :run, false disable :reload get '/' do result = RestClient.get("http://google.com") "Chars on googles page: #{result.size}" end -
MJ
I just wanted to follow up with some recent information.
This problem resurfaced again with the exception:
/usr/lib/ruby/1.8/net/http.rb:560:in
initialize': getaddrinfo: Name or service not known (SocketError)from /usr/lib/ruby/1.8/net/http.rb:560:in `open' from /usr/lib/ruby/1.8/net/http.rb:560:in `connect' from /usr/lib/ruby/1.8/timeout.rb:48:in `timeout' from /usr/lib/ruby/1.8/timeout.rb:76:in `timeout' from /usr/lib/ruby/1.8/net/http.rb:560:in `connect' from /usr/lib/ruby/1.8/net/http.rb:553:in `do_start' from /usr/lib/ruby/1.8/net/http.rb:542:in `start'Switching from a domain name to an IP address produced a different exception:
Errno::EMFILE - Too many open files - socket(2): /usr/lib/ruby/1.8/net/http.rb:560:in `initialize' /usr/lib/ruby/1.8/net/http.rb:560:in `open' /usr/lib/ruby/1.8/net/http.rb:560:in `connect' /usr/lib/ruby/1.8/timeout.rb:48:in `timeout' /usr/lib/ruby/1.8/timeout.rb:76:in `timeout' /usr/lib/ruby/1.8/net/http.rb:560:in `connect' /usr/lib/ruby/1.8/net/http.rb:553:in `do_start' /usr/lib/ruby/1.8/net/http.rb:542:in `start'To correct this issue we raised the max_conns in the config.yml to
max_conns: 1024 max_persistent_conns: 512And this seemed to solve the problem...
-
macournoyer
Do you really have more then 512 open file at the same time? That's a lot. Maybe your connection are not being closed properly.
You can see the open files for a process w/
lsof -p <pid>
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.