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

Reusing http_client instance with proxies #170

Open
glukacsy opened this issue Jun 2, 2016 · 4 comments
Open

Reusing http_client instance with proxies #170

glukacsy opened this issue Jun 2, 2016 · 4 comments
Labels

Comments

@glukacsy
Copy link

glukacsy commented Jun 2, 2016

Hi,

We ran into this weird issue that when we are trying to reuse an http_client instance with an http_config where proxy is set, the first time the request succeeds, but the subsequent times we get error 56, ""Failed to connect to any resolved proxy endpoint".

Tracked this down to http_client_asio.cpp and it almost looks like that the endpoints iterator is incremented the first time and then on subsequent requests points to the end?

Any thoughts?

Also, can you please confirm that in general it is OK (in fact desired) to reuse http_clients for the same base address and then bombard the same instance with ->request calls vs creating a new http_client per request?

regards,
Gergely

@glukacsy glukacsy changed the title Reusing http_client instance wit proxies Reusing http_client instance with proxies Jun 2, 2016
@ras0219-msft
Copy link
Contributor

Yes, reusing http_client's is a best practice if you don't need to change any settings. Currently on Linux, we only pool connections within a single client (PR #156 might change this; it's still uncertain if we can make this work correctly w.r.t. the various settings) which has a significant performance impact.

Looking at http_client_asio.cpp, I don't quite see the issue. The endpoints iterator is incremented, but it's taken by value as a function parameter, so the increment should not affect any other state. Could you walk me through the issue with a bit more detail? Also, are you using HTTP or HTTPS?

@glukacsy
Copy link
Author

glukacsy commented Jun 7, 2016

Thanks for confirming. So all I am doing is (on OS X) to go to System Prefrences/Network/Advanced/Proxies and then set up HTTPS proxy (so to answer your question: I am trying with HTTPS). Then I create an http_client instance, set the proxy on it and make a request, which succeeds - so proxy support is working great. Then I make another request to the same endpoint using the same http_client instance and I am getting error 56. Reproducible.

Regarding http_client_asio.cpp: you are most certainly right, I did not dig into the details, I just saw that that is the actual file where the error code is coming from. Probably I shouldn't have suggested that the issue is with the iterator.

Regards,
Gergely
PS: can you confirm what happens when we re-use the http client instance, but the HTTP connection times out? (e.g. I create instance, make a request, then don't make another request for a long time, but trying to use the same instance again)

@ras0219-msft
Copy link
Contributor

Re: PS
Connection timeouts should be completely transparent; we should open up a new connection automatically and switch over. The timeout process is to remove the socket from the cache under a lock, so you should either successfully get the socket and it won't be timed out, or if it was timed out you won't find any sockets so a new one will open.

@leetal
Copy link
Contributor

leetal commented Aug 14, 2017

Any more updates regarding this issue? It only happens on *NIX platforms it seems. We are experiencing the same issue on OS X/iOS and Linux.

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

No branches or pull requests

3 participants