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

Set proxy per request #3795

Closed
alamothe opened this issue Feb 9, 2021 · 9 comments
Closed

Set proxy per request #3795

alamothe opened this issue Feb 9, 2021 · 9 comments
Assignees
Milestone

Comments

@alamothe
Copy link

alamothe commented Feb 9, 2021

Hello,
We ported our service to use Vert.x awhile ago. While using Vert.x we still used Apache HTTP client without problems. However, now I tried to port also this functionality to Vert.x and I hit a problem.

It seems that Vert.x HttpClient does not allow to set a proxy per request, only on the client level. We use 1000+ proxies simultaneously to scrape websites.

Is there any workaround? How feasible is to create an instance per request?

@vietj
Copy link
Member

vietj commented Feb 9, 2021 via email

@alamothe
Copy link
Author

alamothe commented Feb 9, 2021

Yes. I found the docs here: https://vertx.io/docs/vertx-core/java/#_using_a_proxy_for_httphttps_connections

But it has to be set before creating a client.

How heavy it is to create a client for each request?

@vietj
Copy link
Member

vietj commented Feb 9, 2021 via email

@vietj
Copy link
Member

vietj commented Feb 10, 2021

note also that Vert.x 4.1 should allow to connect to an HTTP server without a connection pool which might make this use case easier.

@vietj
Copy link
Member

vietj commented May 10, 2021

@alamothe I think the point here is pooling because the client might cache a client connection that was established using a specific proxy. In your scenario do you intend to connect to the same server using different proxies ? or will a remote server always use the same proxy ?

@vietj vietj added this to the 4.1.0 milestone May 10, 2021
vietj added a commit that referenced this issue May 12, 2021
Clients have been modified to filter proxy options based on a list of hosts support. Host declaration accept wildcard match like JVM nonProxyHosts list.

HTTP requests declares now a ProxyOptions property that will set the proxy options per request and override the client configuration.

fixes #2600
fixes #3795
vietj added a commit that referenced this issue May 12, 2021
Clients have been modified to filter proxy options based on a list of hosts support. Host declaration accept wildcard match like JVM nonProxyHosts list.

HTTP requests declares now a ProxyOptions property that will set the proxy options per request and override the client configuration.

fixes #2600
fixes #3795
@vietj vietj self-assigned this May 12, 2021
@vietj vietj closed this as completed in 1e95256 May 17, 2021
@alamothe
Copy link
Author

alamothe commented Jul 1, 2021

@vietj Thanks so much for working on this!

In our case, we will connect to the same server using different proxies. It is essential that the connection is not reused if proxies are different even though the destination is the same. Even if just proxy authentication is different, it should not reuse the connection.

Can you please tell me if the implemented solution satisfies this?

Is there any way to attach a "token" to a connection, like in Apache HTTP client?

@vietj
Copy link
Member

vietj commented Jul 2, 2021

you can now have a ProxyOptions per RequestOptions

I don't understand what you mean by token

@alamothe
Copy link
Author

alamothe commented Jul 2, 2021

In Apache HTTP client, you can add a custom "token" to a request (connection), and it will reuse only connections with the sam token.

In our scenario (same server, different proxies), will Vert.x HTTP client try to reuse the connection if it was initiated with a different proxy to the same server?

@vietj
Copy link
Member

vietj commented Jul 5, 2021 via email

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

No branches or pull requests

2 participants