title: Faye, Rails and Net:HTTP end of file reached
body: <p>I am trying to accomplish the following task: as soon a post is approved on the site, people on this site will be informed of that.</p>
  
  <p>To solve this I am using Faye, and publishing on the channel on my method approve. My application has only one channel, really simple scenario. Anyway, for some reason it is not working.</p>
  
  <p>I am using <strong>Rails 2.3.5</strong>, <strong>Faye 0.8.5</strong>, <strong>eventmachine 1.0.0.beta4</strong> (the one installed with Faye), <strong>rack 1.0.1</strong>, and <strong>thin 1.3.1</strong>. I am not using Apache.</p>
  
  <p>What I have so far is:</p>
  
  <p><strong>faye.ru</strong>: (I run it with: rackup faye.ru -s thin -E production)</p>
  
  <pre><code>require 'faye'
  
  faye_server = Faye::RackAdapter.new(:mount =&gt; '/faye', :timeout =&gt; 45)
  run faye_server
  </code></pre>
  
  <p><strong>application.js</strong>:</p>
  
  <pre><code>var $j = jQuery.noConflict();
  
  $j(function() {
    var faye = new Faye.Client('http://0.0.0.0:9292/faye');
    faye.subscribe("/messages/new", function(data) {
      alert(data.text);
    });
  });
  </code></pre>
  
  <p><strong>application.html.erb</strong>:</p>
  
  <pre><code>&lt;%= javascript_include_tag 'http://0.0.0.0:9292/faye.js' %&gt;
  </code></pre>
  
  <p><strong>posts_controller.rb</strong>:</p>
  
  <pre><code>def approve
    @post.update_attribute(:approved, true)
    message = {:post =&gt; @post}
    uri = URI.parse("http://0.0.0.0:9292/faye")
    Net::HTTP.post_form(uri, :message =&gt; message.to_json)
    redirect_to(pending_posts_path)
  end
  </code></pre>
  
  <p>The <strong>stack</strong> trace is:</p>
  
  <pre><code>EOFError (end of file reached):
    /usr/lib/ruby/1.8/net/protocol.rb:135:in `sysread'
    /usr/lib/ruby/1.8/net/protocol.rb:135:in `rbuf_fill'
    /usr/lib/ruby/1.8/timeout.rb:62:in `timeout'
    /usr/lib/ruby/1.8/timeout.rb:93:in `timeout'
    /usr/lib/ruby/1.8/net/protocol.rb:134:in `rbuf_fill'
    /usr/lib/ruby/1.8/net/protocol.rb:116:in `readuntil'
    /usr/lib/ruby/1.8/net/protocol.rb:126:in `readline'
    /usr/lib/ruby/1.8/net/http.rb:2024:in `read_status_line'
    /usr/lib/ruby/1.8/net/http.rb:2013:in `read_new'
    /usr/lib/ruby/1.8/net/http.rb:1050:in `request'
    /usr/lib/ruby/1.8/net/http.rb:405:in `post_form'
    /usr/lib/ruby/1.8/net/http.rb:543:in `start'
    /usr/lib/ruby/1.8/net/http.rb:404:in `post_form'
    app/controllers/posts_controller.rb:38:in `approve'
  </code></pre>
  
  <p>And on the thin server an <strong>error</strong> also appears:</p>
  
  <pre><code>&gt;&gt; Thin web server (v1.3.1 codename Triple Espresso)
  &gt;&gt; Maximum connections set to 1024
  &gt;&gt; Listening on 0.0.0.0:9292, CTRL+C to stop
  !! Unexpected error while processing request: undefined method `call' for nil:NilClass
  </code></pre>
  
  <p>As far as I understood, this error appears everytime I try to connect on the server, and a critical thing is that "http://0.0.0.0:9292/faye.js" is not available, i.e., if I try to access this URL, I receive "<strong>!! Unexpected error while processing request: undefined method `call' for nil:NilClass</strong>", and that is the same reason why Net:HTTP can't access it. I would like to know why.</p>