Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix reconnect on keep alive timeout for passthrough uris. #44

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

dylanahsmith
Copy link

Depends on pull #43 and includes the commit from that pull request. See the second commit for the changes for this pull request.

Problem

pull #43 fixes the following problem when remove connections are allowed to any URI, but not when passthrough uris are registered

Ruby 2.0 added a keep_alive_timeout variable to Net::HTTP for persistent. If keep_alive_timeout seconds has passed between requests, then Net::HTTP will close the socket and call connect. However, fakeweb replaces the connect method to have it do nothing (delaying it until request is called), so the socket is closed without reconnecting on a keep_alive_timeout.

Solution

In this case, it would be preferred to delay the connect on Net::HTTP.start until the request method is called, since fakeweb is in use and we don't want to connect to a remote server when all the requests the a connection will be mocked. However, we want a connect to work inside of request_without_fakeweb due to a keep alive timeout or retry logic.

To accomplish this, I set and reset an instance variable around the call to request_without_fakeweb, then have the connect method actually connect to the remote server if this variable set.

@salimane
Copy link

Any update on this ?

@dcosson
Copy link

dcosson commented Jun 1, 2016

Any update on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants