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

Cross posting this to the rails list in case it might be rails
specific. I really have no clue on this one. OS is Freebsd 6.1.

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) <<— Line 69 in
method authorize

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