Errno::ENXIO (Device not configured) when using net/https from rails

S

snacktime

I have the following code that creates a https connection from within
a rails controller. Works fine except that if it doesn't get called
for a few hours it starts throwing an exception until I restart rails
(apache1.3 + scgi). I wonder if something here isn't thread safe?
Just a guess.

@postdata = nil
headers = { 'Referer' => '', 'Content-Type' =>
'application/x-www-form-urlencoded' }
@postdata = "directauth=1&user=#{user}&pass=#{@password}"
site = Net::HTTP.new( 'mysite.com', 443 )
site.use_ssl = true
response = site.post('/login', @postdata, headers)

And this is the backtrace:

Errno::ENXIO (Device not configured):
/usr/local/lib/ruby/1.8/net/http.rb:566:in `write'
/usr/local/lib/ruby/1.8/net/http.rb:566:in `connect'
/usr/local/lib/ruby/1.8/net/http.rb:555:in `do_start'
/usr/local/lib/ruby/1.8/net/http.rb:544:in `start'
/usr/local/lib/ruby/1.8/net/http.rb:1031:in `request'
/usr/local/lib/ruby/1.8/net/http.rb:840:in `post'
/app/controllers/application.rb:69:in `authorize'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/filters.rb:399:in
`call_filters'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/filters.rb:394:in
`call_filters'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/filters.rb:383:in
`before_action'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/filters.rb:365:in
`perform_action_without_benchmark'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/benchmarking.rb:69:in
`perform_action_without_rescue'
/usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/benchmarking.rb:69:in
`perform_action_without_rescue'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/rescue.rb:82:in
`perform_action'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/base.rb:381:in
`process_without_filters'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/filters.rb:377:in
`process_without_session_management_support'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/session_management.rb:117:in
`process'
/usr/local/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/dispatcher.rb:38:in
`dispatch'
/usr/local/lib/ruby/gems/1.8/gems/scgi_rails-0.4.3/bin/scgi_service:23:in
`process_request'
/usr/local/lib/ruby/1.8/thread.rb:135:in `synchronize'
/usr/local/lib/ruby/gems/1.8/gems/scgi_rails-0.4.3/bin/scgi_service:21:in
`process_request'
/usr/local/lib/ruby/gems/1.8/gems/scgi_rails-0.4.3/lib/scgi.rb:291:in
`read_header'
/usr/local/lib/ruby/gems/1.8/gems/scgi_rails-0.4.3/lib/scgi.rb:253:in
`handle_client'
/usr/local/lib/ruby/gems/1.8/gems/scgi_rails-0.4.3/lib/scgi.rb:234:in
`handle_client'
/usr/local/lib/ruby/gems/1.8/gems/scgi_rails-0.4.3/lib/scgi.rb:188:in
`listen'
/usr/local/lib/ruby/gems/1.8/gems/scgi_rails-0.4.3/lib/scgi.rb:186:in
`listen'
/usr/local/lib/ruby/gems/1.8/gems/scgi_rails-0.4.3/lib/scgi.rb:412:in `run'
/usr/local/lib/ruby/gems/1.8/gems/scgi_rails-0.4.3/bin/scgi_service:61
 
S

snacktime

Also, this is on Freebsd 6.1, and line 68 of the authorize method is
site.post being called.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top