Can you use multiple proxies at once in java?

I encode my server in java, and in a day my server should connect through 5 different proxies simultaneously to other servers and collect data. However, after reading about java proxy settings using stackexchange, I see that when you install the proxy server, its effect is VM-wide, which means any network activity that .jar does, it will do it through the proxy server if somewhere else a thread sets proxy settings in the bank.

I am currently using this proxy setup method, which, according to some tests, is actually very functional and fast.

    System.getProperties().put( "http.proxyHost", host );
    System.getProperties().put( "http.proxyPort", port );

However, I can’t afford to have 5 jars that do the same with different proxies, I tried this, it would be a simple solution, but I can not afford to use this drum just for this, since my server is huge.

+4
source share
2 answers

You need to call each connection with its proxy settings. The answer here from NickDk determines how you can call the url with your proxy settings. You will need to do the same with each of your 5 proxies separately.

+1
source

, JRE, "proxypac", .

JRE, Java proxypac ( ) , .

, , , .

0

Source: https://habr.com/ru/post/1531952/


All Articles