title: Proxy setting not working with Spring WebClient
body: <p>My following WebClient is working fine with internet connection but not through our proxy connection.</p>
  
  <pre><code>WebClient webClient = WebClient.builder()
          .baseUrl("https://targetsite.com")
          .build();
  
  webClient.post()
      .uri("/service/serviceName")
      .body(BodyInserters.fromObject(reqData))
      .retrieve()
      .bodyToMono(WebServiceResponse.class)
  
  </code></pre>
  
  <p>Event though, the same client is working through proxy, if I set it as mentioned below,</p>
  
  <pre><code>HttpClient httpClient = HttpClient.create()
              .tcpConfiguration(tcpClient -&gt; tcpClient
                  .proxy(proxy -&gt; proxy
                      .type(ProxyProvider.Proxy.HTTP)
                      .host("ourproxy.com")
                      .port(8080)));
  
  ReactorClientHttpConnector connector = new ReactorClientHttpConnector(httpClient);
  
  WebClient webClient = WebClient.builder()
          .clientConnector(connector)
          .baseUrl("https://targetsite.com")
          .build();
  
  webClient.post()
      .uri("/service/serviceName")
      .body(BodyInserters.fromObject(reqData))
      .retrieve()
      .bodyToMono(WebServiceResponse.class)
  </code></pre>
  
  <p>But if I set the same Proxy details either using <code>System.setProperty("http.proxyHost","ourproxy.com");</code>
  <code>System.setProperty("http.proxyPort","8080");</code>
  or
  JVM run-time arguments <code>-Dhttp.proxyHost=ourproxy.com -Dhttp.proxyPort=8080</code></p>
  
  <pre><code>WebClient webClient = WebClient.builder()
          .baseUrl("https://targetsite.com")
          .build();
  
  System.setProperty("http.proxyHost", "ourproxy.com");
  System.setProperty("http.proxyPort", "8080");
  
  webClient.post()
      .uri("/service/serviceName")
      .body(BodyInserters.fromObject(reqData))
      .retrieve()
      .bodyToMono(WebServiceResponse.class)
  
  </code></pre>
  
  <p>The calls are getting failed with UnknownHostException like,</p>
  
  <pre><code>[04/11/2019 12:32:43.031 IST] DEBUG [reactor-http-epoll-3] [PooledConnectionProvider:254] - Creating new client pool [http] for targetsite.com:443
  [04/11/2019 12:32:43.033 IST] DEBUG [reactor-http-epoll-3] [PooledConnectionProvider:254] - [id: 0xe4a0dc15] Created new pooled channel, now 0 active connections and 1 inactive connections
  [04/11/2019 12:32:43.045 IST] DEBUG [reactor-http-epoll-3] [SslProvider:254] - [id: 0xe4a0dc15] SSL enabled using engine SSLEngineImpl and SNI targetsite.com:443
  [04/11/2019 12:32:43.046 IST] DEBUG [reactor-http-epoll-3] [BootstrapHandlers:254] - [id: 0xe4a0dc15] Initialized pipeline DefaultChannelPipeline{(reactor.left.sslHandler = io.netty.handler.ssl.SslHandler), (reactor.left.sslReader = reactor.netty.tcp.SslProvider$SslReadHandler), (BootstrapHandlers$BootstrapInitializerHandler#0 = reactor.netty.channel.BootstrapHandlers$BootstrapInitializerHandler), (SimpleChannelPool$1#0 = io.netty.channel.pool.SimpleChannelPool$1), (reactor.left.httpCodec = io.netty.handler.codec.http.HttpClientCodec), (reactor.left.decompressor = io.netty.handler.codec.http.HttpContentDecompressor), (reactor.right.reactiveBridge = reactor.netty.channel.ChannelOperationsHandler)}
  [04/11/2019 12:32:43.165 IST] ERROR [reactor-http-epoll-2] [AbstractErrorWebExceptionHandler:117] - [13ebf1eb] 500 Server Error for HTTP POST "/service/serviceName"
  java.net.UnknownHostException: targetsite.com: Name or service not known
  </code></pre>
  
  <p>Please help, why my code is not functioning if I set the proxy details via JVM run-time arguments or system properties.</p>
  
  <p>Actually I want to avoid code level proxy setting. So please guide me to correct my code or approach, so that I can use JVM run-time argument option.</p>