I have a java app that talks to some REST services, and I want to look at the HTTP traffic using Fiddler.
Fiddler acts as a proxy on localhost:8888, so the following Java VM options are supposed to configure java to use this proxy:
-Dhttp.proxyHost=localhost -Dhttp.proxyPort=8888
However, if I pass these parameters when running the java app that I want to debug, I see no traffic in Fiddler.
I wrote a test Java app that simply performs an HTTP GET using HttpURLConnection.
I can view the HTTP traffic from this app in fiddler, if I specify the above-mentioned command-line parameters when debugging it from Eclipse.
What are the reasons that http.proxyHost/Port might not work for all java HTTP operations?
As mentioned above you need to do something like this:
But that will not be enough.
In TL;DR fashion - you also need all three of these system properties:
-Dhttp.proxyHost=localhost -Dhttp.proxyPort=8888 -Dhttp.nonProxyHosts=
The long answer can be found here:
As mentioned by Gerard Davison at the link above:
For 4.3.6 I used
You can tell HttpClient to honor the JDK system arguments using the below code (HttpClient 4.x).
With Apache httpclient 4.3.6, it seems that you should use SystemDefaultRoutePlanner.
This will pick up the proxy settings from system properties
http.proxyHost
andhttp.proxyPort
, and will use the current settings of those values each time a new http request is sent.