SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Feb 2008
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy RonR - Action Controller problem

    OK, so our webmaster left a several weeks ago, but he designed our Intranet system with Ruby on Rails. I've been trying to learn it (using Build Your Own Ruby on Rails Web Applications) and think I understand it to some degree, but recently, our Intranet is failing when trying to conduct a search. It comes up with this page:

    Errno::EBADF in SearchController#index

    Bad file descriptor - connect(2)

    RAILS_ROOT: E:/webapps/npl/config/..
    Application Trace | Framework Trace | Full Trace

    c:/ruby/lib/ruby/1.8/net/http.rb:560:in `initialize'
    c:/ruby/lib/ruby/1.8/net/http.rb:560:in `open'
    c:/ruby/lib/ruby/1.8/net/http.rb:560:in `connect'
    c:/ruby/lib/ruby/1.8/timeout.rb:48:in `timeout'
    c:/ruby/lib/ruby/1.8/timeout.rb:76:in `timeout'
    c:/ruby/lib/ruby/1.8/net/http.rb:560:in `connect'
    c:/ruby/lib/ruby/1.8/net/http.rb:553:in `do_start'
    c:/ruby/lib/ruby/1.8/net/http.rb:548:in `start'
    c:/ruby/lib/ruby/gems/1.8/gems/mechanize-0.6.10/lib/mechanize.rb:500:in `fetch_page'
    c:/ruby/lib/ruby/gems/1.8/gems/mechanize-0.6.10/lib/mechanize.rb:185:in `get'
    E:/webapps/npl/lib/gsa.rb:76:in `search'
    E:/webapps/npl/lib/gsa.rb:32:in `search'
    E:/webapps/npl/app/controllers/search_controller.rb:16:in `index'

    c:/ruby/lib/ruby/1.8/net/http.rb:560:in `initialize'
    c:/ruby/lib/ruby/1.8/net/http.rb:560:in `open'
    c:/ruby/lib/ruby/1.8/net/http.rb:560:in `connect'
    c:/ruby/lib/ruby/1.8/timeout.rb:48:in `timeout'
    c:/ruby/lib/ruby/1.8/timeout.rb:76:in `timeout'
    c:/ruby/lib/ruby/1.8/net/http.rb:560:in `connect'
    c:/ruby/lib/ruby/1.8/net/http.rb:553:in `do_start'
    c:/ruby/lib/ruby/1.8/net/http.rb:548:in `start'
    c:/ruby/lib/ruby/gems/1.8/gems/mechanize-0.6.10/lib/mechanize.rb:500:in `fetch_page'
    c:/ruby/lib/ruby/gems/1.8/gems/mechanize-0.6.10/lib/mechanize.rb:185:in `get'
    E:/webapps/npl/vendor/rails/actionpack/lib/action_controller/base.rb:1101:in `send'
    E:/webapps/npl/vendor/rails/actionpack/lib/action_controller/base.rb:1101:in `perform_action_without_filters'
    E:/webapps/npl/vendor/rails/actionpack/lib/action_controller/filters.rb:696:in `call_filters'
    E:/webapps/npl/vendor/rails/actionpack/lib/action_controller/filters.rb:688:in `perform_action_without_benchmark'
    E:/webapps/npl/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:66:in `perform_action_without_rescue'
    c:/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure'
    E:/webapps/npl/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:66:in `perform_action_without_rescue'
    E:/webapps/npl/vendor/rails/actionpack/lib/action_controller/rescue.rb:83:in `perform_action'
    E:/webapps/npl/vendor/rails/actionpack/lib/action_controller/base.rb:435:in `send'
    E:/webapps/npl/vendor/rails/actionpack/lib/action_controller/base.rb:435:in `process_without_filters'
    E:/webapps/npl/vendor/rails/actionpack/lib/action_controller/filters.rb:684:in `process_without_session_management_support'
    E:/webapps/npl/vendor/rails/actionpack/lib/action_controller/session_management.rb:114:in `process'
    E:/webapps/npl/vendor/rails/actionpack/lib/action_controller/base.rb:334:in `process'
    E:/webapps/npl/vendor/rails/railties/lib/dispatcher.rb:41:in `dispatch'
    c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1-mswin32/lib/mongrel/rails.rb:76:in `process'
    c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1-mswin32/lib/mongrel/rails.rb:74:in `synchronize'
    c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1-mswin32/lib/mongrel/rails.rb:74:in `process'
    c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1-mswin32/lib/mongrel.rb:155:in `process_client'
    c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1-mswin32/lib/mongrel.rb:154:in `each'
    c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1-mswin32/lib/mongrel.rb:154:in `process_client'
    c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1-mswin32/lib/mongrel.rb:281:in `run'
    c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1-mswin32/lib/mongrel.rb:281:in `initialize'
    c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1-mswin32/lib/mongrel.rb:281:in `new'
    c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1-mswin32/lib/mongrel.rb:281:in `run'
    c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1-mswin32/lib/mongrel.rb:264:in `initialize'
    c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1-mswin32/lib/mongrel.rb:264:in `new'
    c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1-mswin32/lib/mongrel.rb:264:in `run'
    c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1-mswin32/lib/mongrel/configurator.rb:282:in `run'
    c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1-mswin32/lib/mongrel/configurator.rb:281:in `each'
    c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1-mswin32/lib/mongrel/configurator.rb:281:in `run'
    c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1-mswin32/bin/mongrel_rails:126:in `run'
    c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1-mswin32/lib/mongrel/command.rb:212:in `run'
    c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1-mswin32/bin/mongrel_rails:279
    c:/ruby/bin/mongrel_rails:16:in `load'
    c:/ruby/bin/mongrel_rails:16

    c:/ruby/lib/ruby/1.8/net/http.rb:560:in `initialize'
    c:/ruby/lib/ruby/1.8/net/http.rb:560:in `open'
    c:/ruby/lib/ruby/1.8/net/http.rb:560:in `connect'
    c:/ruby/lib/ruby/1.8/timeout.rb:48:in `timeout'
    c:/ruby/lib/ruby/1.8/timeout.rb:76:in `timeout'
    c:/ruby/lib/ruby/1.8/net/http.rb:560:in `connect'
    c:/ruby/lib/ruby/1.8/net/http.rb:553:in `do_start'
    c:/ruby/lib/ruby/1.8/net/http.rb:548:in `start'
    c:/ruby/lib/ruby/gems/1.8/gems/mechanize-0.6.10/lib/mechanize.rb:500:in `fetch_page'
    c:/ruby/lib/ruby/gems/1.8/gems/mechanize-0.6.10/lib/mechanize.rb:185:in `get'
    E:/webapps/npl/lib/gsa.rb:76:in `search'
    E:/webapps/npl/lib/gsa.rb:32:in `search'
    E:/webapps/npl/app/controllers/search_controller.rb:16:in `index'
    E:/webapps/npl/vendor/rails/actionpack/lib/action_controller/base.rb:1101:in `send'
    E:/webapps/npl/vendor/rails/actionpack/lib/action_controller/base.rb:1101:in `perform_action_without_filters'
    E:/webapps/npl/vendor/rails/actionpack/lib/action_controller/filters.rb:696:in `call_filters'
    E:/webapps/npl/vendor/rails/actionpack/lib/action_controller/filters.rb:688:in `perform_action_without_benchmark'
    E:/webapps/npl/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:66:in `perform_action_without_rescue'
    c:/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure'
    E:/webapps/npl/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:66:in `perform_action_without_rescue'
    E:/webapps/npl/vendor/rails/actionpack/lib/action_controller/rescue.rb:83:in `perform_action'
    E:/webapps/npl/vendor/rails/actionpack/lib/action_controller/base.rb:435:in `send'
    E:/webapps/npl/vendor/rails/actionpack/lib/action_controller/base.rb:435:in `process_without_filters'
    E:/webapps/npl/vendor/rails/actionpack/lib/action_controller/filters.rb:684:in `process_without_session_management_support'
    E:/webapps/npl/vendor/rails/actionpack/lib/action_controller/session_management.rb:114:in `process'
    E:/webapps/npl/vendor/rails/actionpack/lib/action_controller/base.rb:334:in `process'
    E:/webapps/npl/vendor/rails/railties/lib/dispatcher.rb:41:in `dispatch'
    c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1-mswin32/lib/mongrel/rails.rb:76:in `process'
    c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1-mswin32/lib/mongrel/rails.rb:74:in `synchronize'
    c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1-mswin32/lib/mongrel/rails.rb:74:in `process'
    c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1-mswin32/lib/mongrel.rb:155:in `process_client'
    c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1-mswin32/lib/mongrel.rb:154:in `each'
    c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1-mswin32/lib/mongrel.rb:154:in `process_client'
    c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1-mswin32/lib/mongrel.rb:281:in `run'
    c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1-mswin32/lib/mongrel.rb:281:in `initialize'
    c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1-mswin32/lib/mongrel.rb:281:in `new'
    c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1-mswin32/lib/mongrel.rb:281:in `run'
    c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1-mswin32/lib/mongrel.rb:264:in `initialize'
    c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1-mswin32/lib/mongrel.rb:264:in `new'
    c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1-mswin32/lib/mongrel.rb:264:in `run'
    c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1-mswin32/lib/mongrel/configurator.rb:282:in `run'
    c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1-mswin32/lib/mongrel/configurator.rb:281:in `each'
    c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1-mswin32/lib/mongrel/configurator.rb:281:in `run'
    c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1-mswin32/bin/mongrel_rails:126:in `run'
    c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1-mswin32/lib/mongrel/command.rb:212:in `run'
    c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1-mswin32/bin/mongrel_rails:279
    c:/ruby/bin/mongrel_rails:16:in `load'
    c:/ruby/bin/mongrel_rails:16

    Request

    Parameters: {"commit"=>"Search", "q"=>"sampling", "as_sitesearch"=>nil}

    Show session dump

    ---
    :user: !ruby/object:User
    attributes:
    created_on: 2007-11-14T13:15:13+00:00
    employeeid: "xxxxxxx"
    displayname: xxxxxxxxxxxx (Library)
    updated_on: 2008-01-28T07:58:23+00:00
    search_engine: 0
    username: jmcgranahan
    mail: xxxxx.xxxxxxxxx@xxxxx.xxx
    id: 437
    description: Main\Technical Services
    telephonenumber: 615-862-5800
    department_id: 5
    local_password:
    active: 1
    password: xxxxxxxxxxxx
    flash: !map:ActionController::Flash::FlashHash {}


    Response
    Headers: {"cookie"=>[], "Cache-Control"=>"no-cache"}
    -----------------
    I'm just not sure how to troubleshoot this. I've looked at the searchcontroller file and didn't see anything obviously wrong, and I've not made any changes to it, so where should I even begin to look? Please help. Thank you!

    Jamen McGranahan
    Last edited by jmcgranahan; May 1, 2008 at 11:52.

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,290
    Mentioned
    198 Post(s)
    Tagged
    3 Thread(s)

    error message

    I must apologize that I'm very much a Ruby newbie. I have just started reading the same book. So you know more about Ruby than I do. In fact I haven't gotten to syntax yet. But I have lot's of experience with error messages
    Code:
    Bad file descriptor - connect(2)
    suggests 2 things to me. The "file descriptor" (2 ?), either is passed in the wrong syntax, ie, missing quotes, wrong type, or maybe the path/filename is incorrect. Have you recently renamed or removed any files that the problem file may be referring to?
    The "connect" sounds like a database related problem. Since the search was last working correctly have you changed any config values, ie. databasename, user, password etc?
    BTW, if that is a real email address in your post I suggest you edit it out before it becomes SPAM bait. And maybe your "username" and any other potentially sensitive config info too.

  3. #3
    SitePoint Wizard samsm's Avatar
    Join Date
    Nov 2001
    Location
    Atlanta, GA, USA
    Posts
    5,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Mechanize (in the stack trace) is a scripted browser ... you say things like go the third link, fillout the second form on that page, then click the ok button ... mechanize keeps track of the cookies and such, just like a browser would.

    I'd guess that error is probably mechanize failing to connect to "the third link on the page" or something. I'd look at what addresses mechanize is trying to get.

    If this only happens occasionally, you might consider error handling the problem ... just suggest people try again.
    Code Ruby:
    begin
      # code that errors here
    rescue Errno::EBADF => e
      # e will contain some info about the error
      render :action => 'connection_error_sry_kthx'
    end
    Using your unpaid time to add free content to SitePoint Pty Ltd's portfolio?

  4. #4
    SitePoint Member
    Join Date
    Feb 2008
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    I guess I still don't understand

    The search is using search_controller.rb. Here's the code from that file:

    # Sends search requests of our CMS to the Google Mini appliance for processing,
    # filters and decorates the responses
    class SearchController < ApplicationController
    OUR_MINI = GSA::Appliance.new('search.library.nashville.org')

    # All search requests must be authenticated so we know what the user is
    # allowed to see
    before_filter :authenticate_user

    def index
    # Construct search parameters
    my_params = {'as_sitesearch'=>params[:as_sitesearch]}
    my_params['start'] = params[:start] if params[:start]
    begin
    # Do the search
    @search = OUR_MINI.search(params[:q], my_params)
    rescue WWW::Mechanize::ResponseCodeError => e
    # Probably we should do something better if the appliance fails
    logger.error("Response code: #{e.response_code}")
    raise e
    end
    # If the search was limited to a specific directory, figure out which,
    # if any, directory of the node tree to which it was limited and store
    # that in the @sitesearch_node so we can display it in the view
    if site_uri_param = @search.params['as_sitesearch']
    site_uri = URI:****(site_uri_param)
    site_params = ::ActionController::Routing::Routes.recognize_path(site_uri.path)
    if site_params[:controller] == 'nodes' && site_params[:action] == 'path'
    @sitesearch_node = Node.from_paths(site_params[ath])
    end
    end
    # Filter the results for readability and decorate them with the extra views
    # and recent derived attributes
    @results = (@search.results || []).select do |r|
    result_uri = URI:****(r.uri)
    readable = false
    begin
    result_params = ::ActionController::Routing::Routes.recognize_path(result_uri.path)
    rescue ::ActionController::RoutingError
    logger.error("No route for #{result_uri.path}")
    result_params = {}
    if result_uri.path == '/nodes/'
    # FIXME - we should probably redirect /nodes/ to /nodes/path/News
    # to avoid having to code in this ugliness
    result_params[:controller] = 'nodes'
    result_params[:action] = 'path'
    result_params[ath] = ['News']
    end
    end
    if result_params[:controller] == 'nodes' && result_params[:action] == 'path'
    node = Node.from_paths(result_params[ath])
    if node
    if readable = node.can?(@user, :read)
    # decorate the node with extra attributes
    # FIXME - this duplicates code in nodes_controller. Does this
    # perhaps speak to the need for a VIEW of the nodes table?
    extra_attrs = node.connection.select_one("SELECT (SELECT COUNT(*) AS cnt FROM node_logs WHERE node_id = id) AS views, CASE when DATEDIFF(month, file_modified_on, GETDATE()) < 3 THEN 1 ELSE 0 END AS recent FROM nodes WHERE id = #{node.id}")
    class << node
    attr_accessor :views, :recent, :snippet
    end
    node.views = extra_attrs['views']
    node.recent = extra_attrs['recent']
    node.snippet = r.snippet
    # decorate the result with the node
    class << r
    attr_accessor :node
    end
    r.node = node
    end
    end
    end
    readable
    end
    if @search.results
    skipped = @search.results.length - @results.length
    @total = @search.results.total - skipped
    @last = @search.results.last - skipped
    @first = @search.results.first
    end
    end
    end

    ----------------
    I'm just not sure how to troubleshoot this. Samsn, you state "I'd look at what addresses mechanize is trying to get." Are you referring to this line?:

    OUR_MINI = GSA::Appliance.new('search.library.nashville.org')

    And honestly, I don't know when the search "broke". It was just reported to me earlier this week, but it could have been "broken" before then and 1) either no one reported it or 2) no one tried the search function. Any help you can provide would be greatly appreciated. Thank you!

    Jamen

  5. #5
    SitePoint Evangelist
    Join Date
    Feb 2006
    Location
    Worcs. UK
    Posts
    404
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    When you are posting code to this forum, you can put tags around it to signify that this is code. This will stop the parser doing things like converting some character sequences to smilies and preserving you tabs so your code is more readable. You enter code samples like this:
    HTML Code:
    [code]
    def a_method
      return 3
    end
    [/code]

  6. #6
    Avid Logophile silver trophy
    ParkinT's Avatar
    Join Date
    May 2006
    Location
    Central Florida
    Posts
    2,345
    Mentioned
    192 Post(s)
    Tagged
    5 Thread(s)
    "...but recently, our Intranet is failing when trying to conduct a search"
    Standard (logical) troubleshooting indicates if:
    It was working correctly at one time
    It (seemingly) suddenly stopped working
    Something changed

    If the Ruby on Rails code was not altered that is not what changed.
    It appears to rely on several external operations (GSA::Appliance and mechanize). I suggest you look there first.

    Secondly, if you can carefully "code around" (remark out or stub out) those dependencies and watch how the errors change. There WILL BE errors because the search cannot be performed without that external library. But changes in the error can help you, acts_as_detective, track down the root cause.
    Don't be yourself. Be someone a little nicer. -Mignon McLaughlin, journalist and author (1913-1983)


    Git is for EVERYONE
    Literally, the best app for readers.
    Make Your P@ssw0rd Secure
    Leveraging SubDomains


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •