How to fix timeout error

37 views
Skip to first unread message

染谷洋平

unread,
Jul 14, 2017, 1:17:58 AM7/14/17
to http.rb: a fast, easy-to-use Ruby HTTP client with a chainable API
I use http and access to fluentd server.

The procession is here.

  def input_fluentd(body)

    HTTP.timeout(write: 1, connect: 1, read: 1).post("#{ENV['FLUENTD_ENDPOINT_HTTP']}/user_action", json: body)

  end


However, I get errors like below sometimes.
There are not a lot of accesses and the max of query per second is about 20.
What should I do?

```
*A* `HTTP::TimeoutError` *occured in background*
Exception
----------------
execution expired

Hostname
----------------
24b9d913-0d52-4f58-b391-c504acab50fa

Backtrace
----------------
```/app/vendor/bundle/ruby/2.3.0/gems/http-2.1.0/lib/http/timeout/per_operation.rb:25:in `initialize'
/app/vendor/bundle/ruby/2.3.0/gems/http-2.1.0/lib/http/timeout/per_operation.rb:25:in `open'
/app/vendor/bundle/ruby/2.3.0/gems/http-2.1.0/lib/http/timeout/per_operation.rb:25:in `block in connect'
/app/vendor/ruby-2.3.1/lib/ruby/2.3.0/timeout.rb:101:in `timeout'
/app/vendor/bundle/ruby/2.3.0/gems/http-2.1.0/lib/http/timeout/per_operation.rb:24:in `connect'
/app/vendor/bundle/ruby/2.3.0/gems/http-2.1.0/lib/http/connection.rb:41:in `initialize'
/app/vendor/bundle/ruby/2.3.0/gems/http-2.1.0/lib/http/client.rb:60:in `new'
/app/vendor/bundle/ruby/2.3.0/gems/http-2.1.0/lib/http/client.rb:60:in `perform'
/app/vendor/bundle/ruby/2.3.0/gems/http-2.1.0/lib/http/client.rb:41:in `request'
/app/vendor/bundle/ruby/2.3.0/gems/http-2.1.0/lib/http/chainable.rb:26:in `post'
/app/app/controllers/application_controller.rb:100:in `input_fluentd'
/app/app/controllers/application_controller.rb:93:in `logging_handler'
/app/app/controllers/tracking_events_controller.rb:8:in `log_tracking'
/app/vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.1.rc2/lib/action_controller/metal/basic_implicit_render.rb:4:in `send_action'
/app/vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.1.rc2/lib/abstract_controller/base.rb:188:in `process_action'
/app/vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.1.rc2/lib/action_controller/metal/rendering.rb:30:in `process_action'
/app/vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.1.rc2/lib/abstract_controller/callbacks.rb:20:in `block in process_action'
/app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.1.rc2/lib/active_support/callbacks.rb:126:in `call'
/app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.1.rc2/lib/active_support/callbacks.rb:506:in `block (2 levels) in compile'
/app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.1.rc2/lib/active_support/callbacks.rb:455:in `call'
/app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.1.rc2/lib/active_support/callbacks.rb:101:…
```

and 

```
*A* `HTTP::TimeoutError` *occured in background*
Exception
----------------
Read timed out after 1 seconds

Hostname
----------------
5b386525-7f19-4e9a-91ed-2da627a1d14a

Backtrace
----------------
```/app/vendor/bundle/ruby/2.3.0/gems/http-2.1.0/lib/http/timeout/per_operation.rb:69:in `block in readpartial'
/app/vendor/bundle/ruby/2.3.0/gems/http-2.1.0/lib/http/timeout/per_operation.rb:62:in `loop'
/app/vendor/bundle/ruby/2.3.0/gems/http-2.1.0/lib/http/timeout/per_operation.rb:62:in `readpartial'
/app/vendor/bundle/ruby/2.3.0/gems/http-2.1.0/lib/http/connection.rb:212:in `read_more'
/app/vendor/bundle/ruby/2.3.0/gems/http-2.1.0/lib/http/connection.rb:99:in `block in read_headers!'
/app/vendor/bundle/ruby/2.3.0/gems/http-2.1.0/lib/http/connection.rb:98:in `loop'
/app/vendor/bundle/ruby/2.3.0/gems/http-2.1.0/lib/http/connection.rb:98:in `read_headers!'
/app/vendor/bundle/ruby/2.3.0/gems/http-2.1.0/lib/http/client.rb:64:in `perform'
/app/vendor/bundle/ruby/2.3.0/gems/http-2.1.0/lib/http/client.rb:41:in `request'
/app/vendor/bundle/ruby/2.3.0/gems/http-2.1.0/lib/http/chainable.rb:26:in `post'
/app/app/controllers/application_controller.rb:100:in `input_fluentd'
/app/app/controllers/application_controller.rb:93:in `logging_handler'
/app/app/controllers/tracking_events_controller.rb:8:in `log_tracking'
/app/vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.1.rc2/lib/action_controller/metal/basic_implicit_render.rb:4:in `send_action'
/app/vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.1.rc2/lib/abstract_controller/base.rb:188:in `process_action'
/app/vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.1.rc2/lib/action_controller/metal/rendering.rb:30:in `process_action'
/app/vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.1.rc2/lib/abstract_controller/callbacks.rb:20:in `block in process_action'
/app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.1.rc2/lib/active_support/callbacks.rb:126:in `call'
/app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.1.rc2/lib/active_support/callbacks.rb:506:in `block (2 levels) in compile'
/app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.1.rc2/lib/active_support/callbacks.rb:455:in `call'
/app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.1.r…
```

Tony Arcieri

unread,
Jul 14, 2017, 1:55:18 PM7/14/17
to 染谷洋平, http.rb: a fast, easy-to-use Ruby HTTP client with a chainable API
That error indicates a timeout occurred.

You either need to increase the timeout or retry when timeouts occur.

--
You received this message because you are subscribed to the Google Groups "http.rb: a fast, easy-to-use Ruby HTTP client with a chainable API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to httprb+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Tony Arcieri

染谷洋平

unread,
Jul 30, 2017, 1:08:54 PM7/30/17
to Tony Arcieri, http.rb: a fast, easy-to-use Ruby HTTP client with a chainable API
I'm sorry for late reply.
Thanks! 

2017年7月15日(土) 2:55 Tony Arcieri <bas...@gmail.com>:
To unsubscribe from this group and stop receiving emails from it, send an email to httprb+un...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Tony Arcieri
Reply all
Reply to author
Forward
0 new messages