Project

General

Profile

Feature #10674

Net::HTTP retries idempotent requests once after a timeout, but its not configurable

Added by jlecour (Jérémy Lecour) over 4 years ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal
Target version:
-
[ruby-core:67206]

Description

Hi,

I've noticed that Net::HTTP retries idempotent requests once after a time-out. It seems to adhere to the RFC 2616 (http://tools.ietf.org/html/rfc2616), but it is not always the best thing to do.

When you don't know exactly how a remote web service works, it may be wise to retry after a time-out.
But when you know that a retry won't change anything, it should be possible to disable this automatic retry. Otherwise, the server will have to deal with 2 requests (instead of 1) and the client will effectively time-out twice later than expected (time for the first and second time-out).

Having a basic "#retry=" (like we have "#read_timeout=" or "#open_timeout" would be good first step.
The value could be a simple boolean, or even an integer for the maximum number of retries.

The "Retry" middleware in Faraday has a more comprehensive feature set with max retries, exponential back-off, … : https://github.com/lostisland/faraday/blob/master/lib/faraday/request/retry.rb

Associated revisions

Revision 4f4d7247
Added by naruse (Yui NARUSE) over 1 year ago

Make retries for Net::HTTP configurable [Feature #10674]

by stereobooster
fix https://github.com/ruby/ruby/pull/1654

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60035 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 60035
Added by naruse (Yui NARUSE) over 1 year ago

Make retries for Net::HTTP configurable [Feature #10674]

by stereobooster
fix https://github.com/ruby/ruby/pull/1654

Revision 60035
Added by naruse (Yui NARUSE) over 1 year ago

Make retries for Net::HTTP configurable [Feature #10674]

by stereobooster
fix https://github.com/ruby/ruby/pull/1654

Revision 60035
Added by naruse (Yui NARUSE) over 1 year ago

Make retries for Net::HTTP configurable [Feature #10674]

by stereobooster
fix https://github.com/ruby/ruby/pull/1654

History

Updated by shulmang (Garett Shulman) over 3 years ago

I can confirm this exact behavior on 2.1.7

Updated by cben (Beni Cherniavsky-Paskin) about 2 years ago

Can confirm on 2.4.1.
The responsible code is here: https://github.com/ruby/ruby/blob/v2_4_1/lib/net/http.rb#L1468
I'm thinking of making a simple patch adding a boolean "#retry=". Application or higher-level gems can then implement any retry logic...

Updated by naruse (Yui NARUSE) almost 2 years ago

  • Assignee changed from drbrain (Eric Hodel) to naruse (Yui NARUSE)
  • Status changed from Open to Assigned
#4

Updated by naruse (Yui NARUSE) over 1 year ago

  • Status changed from Assigned to Closed

Applied in changeset trunk|r60035.


Make retries for Net::HTTP configurable [Feature #10674]

by stereobooster
fix https://github.com/ruby/ruby/pull/1654

Also available in: Atom PDF