ruby-amqp/rpc — pull request #3 by harigopal (2011-12-08 07:23:19+00:00)
Title: Rescuing EOFError on post request

Hi,

Net::Protocol throws EOFError after a few minutes of idling on a connection. The client resumes working after the EOFError is thrown, so I thought it'd be straight-forward to push the retry into the gem instead of having to encase all RPC method calls in begin-rescue (EOFError) loops.

I'm not sure whether this is the 'right' way to fix this, though. It'd be great if you could take a look.

How to replicate the issue, in the absence of the patch:

```ruby
client = RPC::Client.setup("http://server/url")
# => "baz"}>

client.some_method
# => "foobar"

# Wait a few minutes...

client.some_method
EOFError: end of file reached
from ~/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/protocol.rb:135:in `read_nonblock'
from ~/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/protocol.rb:135:in `rbuf_fill'
from ~/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/protocol.rb:116:in `readuntil'
from ~/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/protocol.rb:126:in `readline'
from ~/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/http.rb:2219:in `read_status_line'
from ~/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/http.rb:2208:in `read_new'
from ~/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/http.rb:1191:in `transport_request'
from ~/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/http.rb:1177:in `request'
from ~/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/http.rb:978:in `post'

# Immediately afterward...
client.some_method
# => "foobar"
```