ERROR Errno::ECONNRESET: Connection reset by peer @ io_fillbuf.

5,749 views
Skip to first unread message

ruby user

unread,
Aug 30, 2014, 8:28:16 AM8/30/14
to rubyonra...@googlegroups.com

I am getting problems with a json request using the rails api gem and webrick.

When i do a index search with GET, i have an error ERROR Errno::ECONNRESET: Connection reset by peer @ io_fillbuf. Below is a full log of the problem.I have been trying to google the io_fillbuf but i can’t seem to find any clear answers to what it is.

In my ApplicationController i have “skip_before_action :verify_authenticity_token” as I am just using rails api for a pure json app.

Started GET "/api/v1/images.json?type=index&more=yes&offset=80" for 169.254.249.61 at 2014-08-21 10:30:15 Processing by Api::V1::ImagesController#index as JSON

Parameters: {"type"=>"index", "more"=>"yes", "offset"=>"80"} index

params type index
images length 20
Completed 200 OK in 97ms (Views: 0.1ms | ActiveRecord: 0.0ms)
[2014-08-21 10:30:15] ERROR Errno::ECONNRESET: Connection reset by peer @ io_fillbuf - fd:19

/Users/user/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/webrick/httpserver.rb:80:in `eof?' /Users/user/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/webrick/httpserver.rb:80:in `run' /Users/user/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/webrick/server.rb:295:in `block in start_thread'

[2014-08-21 10:30:15] ERROR Errno::ECONNRESET: Connection reset by peer @ io_fillbuf - fd:15 /Users/user/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/webrick/httpserver.rb:80:in `eof?' /Users/user/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/webrick/httpserver.rb:80:in `run' /Users/user/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/webrick/server.rb:295:in `block in start_thread'

[2014-08-21 10:30:15] ERROR Errno::ECONNRESET: Connection reset by peer @ io_fillbuf - fd:18 /Users/user/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/webrick/httpserver.rb:80:in `eof?' /Users/user/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/webrick/httpserver.rb:80:in `run' /Users/user/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/webrick/server.rb:295:in `block in start_thread'

[2014-08-21 10:30:15] ERROR Errno::ECONNRESET: Connection reset by peer @ io_fillbuf - fd:15 /Users/user/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/webrick/httpserver.rb:80:in `eof?' /Users/user/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/webrick/httpserver.rb:80:in `run' /Users/user/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/webrick/server.rb:295:in `block in start_thread'

[2014-08-21 10:30:15] ERROR Errno::ECONNRESET: Connection reset by peer @ io_fillbuf - fd:18 /Users/user/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/webrick/httpserver.rb:80:in `eof?' /Users/user/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/webrick/httpserver.rb:80:in `run' /Users/user/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/webrick/server.rb:295:in `block in start_thread' 

Colin Law

unread,
Aug 30, 2014, 8:54:58 AM8/30/14
to rubyonra...@googlegroups.com
On 30 August 2014 13:28, ruby user <tyl...@gmail.com> wrote:
> I am getting problems with a json request using the rails api gem and
> webrick.
>
> When i do a index search with GET, i have an error ERROR Errno::ECONNRESET:
> Connection reset by peer @ io_fillbuf. Below is a full log of the problem.I
> have been trying to google the io_fillbuf but i can’t seem to find any clear
> answers to what it is.
>
> In my ApplicationController i have “skip_before_action
> :verify_authenticity_token” as I am just using rails api for a pure json
> app.
>
> Started GET "/api/v1/images.json?type=index&more=yes&offset=80" for
> 169.254.249.61 at 2014-08-21 10:30:15 Processing by
> Api::V1::ImagesController#index as JSON
>
> Parameters: {"type"=>"index", "more"=>"yes", "offset"=>"80"} index
>
> params type index
> images length 20
> Completed 200 OK in 97ms (Views: 0.1ms | ActiveRecord: 0.0ms)
> [2014-08-21 10:30:15] ERROR Errno::ECONNRESET: Connection reset by peer @
> io_fillbuf - fd:19

Is it trying to fetch something from another server? If so perhaps
that connection is failing.
Show us ImagesController#index
Does it happen every time you perform the request?

Colin

ruby user

unread,
Aug 30, 2014, 11:42:39 AM8/30/14
to rubyonra...@googlegroups.com

It is not trying to fetch anything from another server.

It does not happen every time i perform the request. Only once when i was requesting the page. 


def index

  images = Image.order("id DESC").limit(IMAGES_PER_PAGE+1).offset(offset) 

  if images.length > IMAGES_PER_PAGE

    hasMore = "yes"

    images = images.first(IMAGES_PER_PAGE)

    offset = offset + IMAGES_PER_PAGE

  end

  finaljson = {:type => "index", :offset => offset, :iteration => 0, :limit => IMAGES_PER_PAGE, , :images => images}

  render :status=>200, :json => finaljson.to_json(:include => :comments)

end

Jason Fleetwood-Boldt

unread,
Sep 2, 2014, 12:17:12 PM9/2/14
to rubyonra...@googlegroups.com

On the Heroku platform I always see an intermittent (and usually very rare) occurrence of "Connection reset by peer" on ALL external services -- Redis, database, etc. I believe this to be network-related and there's little you can do to prevent it.

Typically my application controller has several rescue_from(s) to deal with all of these exceptions, gracefully informing the user that there was a momentary problem and to please try again.

If it happens with frequency, figure out which external service is the problem and take it up with your hosting provider or the provider for the external service.
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLurHywC%3DvSaJQ_H2Vt309Sot%2B%3D78PbC9J4AF%2B%3DUCqwMVw%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>

Jason Fleetwood-Boldt

unread,
Sep 2, 2014, 12:19:46 PM9/2/14
to rubyonra...@googlegroups.com


It could happen just talking to the database. Can you investigate if that query is prohibitively expensive or causes the database to hit a bottleneck?

ruby user

unread,
Sep 2, 2014, 3:10:39 PM9/2/14
to rubyonra...@googlegroups.com
Its shouldn't be prohibitively expensive, I'll have to run more extensive test to analyze the cost.
Reply all
Reply to author
Forward
0 new messages