Running vertx behind a proxy

Has anyone had any luck trying to use vertx bihind for a corporate proxy? I tried all the possible ways that come to my mind to provide proxy information in vertx. Nothing is working yet.

set environment variable http_proxy = http://mycorporate.proxy.com:8080 - no luck

set the environment variable VERTX_OPTS = '- Dhttp.proxyHost = mycorporate.proxy.com -Dhttp.proxyPort = 8080' - no luck

set environment variables http.proxyHost = mycorporate.proxy.com http.proxyPort = 8080 no luck

Embedding an additional echo in the vertx command. I see that the parameters related to the proxy server are passed to the JVM correctly, but the required module still cannot be loaded ("vertx run hello.js" just got stuck, obviously trying to load io.vertx ~ lang -rhino ~ 2.0. 0-end)

The proxy itself is normal - I use it without problems for maven, sbt and other things that require a proxy server. The same laptop that is used from home can successfully run "vertx run hello.js" with loading io.vertx ~ lang-rhino ~ 2.0.0-final (for the first run)

I have just started evaluating vertx for the needs of our company, and this is my very first choking, which impedes my further attempts to make a decision. So far, I had to follow the following steps as a workaround: 1 Run from home and get all the necessary modules in sys-mods. 2 Manually load the module (s) into sys-mods on the test server when you return to the office. Obviously, this is not the usual way to run anything.

+4
source share
3 answers

I had a similar problem. I understand that the HttpClient form does not read settings from JVM_OPTS. Therefore, the solution is as follows:

Edit the file vertx.bat (sh)

set JVM_OPTS=-Dhttp.proxyHost=xxxx -Dhttp.proxyPort=xxxx

and then in the code related to httpClient try sth like this

   HttpClient client = vertx.createHttpClient();
    String proxyHost = System.getProperty("http.proxyHost", "none");
    Integer proxyPort = Integer.valueOf(System.getProperty("http.proxyPort", "80"));

    if(!"none".equalsIgnoreCase(proxyHost)){

        client.setHost(proxyHost);
        client.setPort(proxyPort);
    }

and then in the code rewritten by the HTTP request

   MultiMap map = new CaseInsensitiveMultiMap();
   map.add("Host", domainName); //get domain of REQUESTED_URL                 
   client.getNow(REQUESTED_URL, map, new new Handler<HttpClientResponse>(){...});
0

@kamyk-pl . Vertx, , :

    WebClientOptions webClientOptions = new WebClientOptions();
    String proxyHost = System.getProperty("http.proxyHost", "none");
    Integer proxyPort = Integer.valueOf(System.getProperty("http.proxyPort", "80"));

    if(!"none".equalsIgnoreCase(proxyHost)){
        ProxyOptions proxyOptions = new ProxyOptions();
        proxyOptions.setHost(proxyHost);
        proxyOptions.setPort(proxyPort);
        webClientOptions.setProxyOptions(proxyOptions);
    }

     WebClient.create(vertx, webClientOptions) 

, SSL-

        webClientOptions.setVerifyHost(false);
        webClientOptions.setTrustAll(true);
0

To install the proxy, edit the vertx.bat file (if you are on Windows) and add

set JVM_OPTS=-Dhttp.proxyHost=xxxx -Dhttp.proxyPort=xxxx
-1
source

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


All Articles