I am getting Connection timed out: connect
.
My code:
System.setProperty("http.proxyHost", "proxy.mycompany.com");
System.setProperty("http.proxyPort", "8080");
String url = URL_BASE + "&limit=5";
URL u = new URL(url);
BufferedReader in = new BufferedReader(
new InputStreamReader(
u.openStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();
If you're fetching a URL on HTTPS, then you must set https.proxyHost
and https.proxyPort
. See documentation on Java Networking and Proxies , section 2.2.
System.setProperty("https.proxyHost", "proxy.mycompany.com");
System.setProperty("https.proxyPort", "8080");
assuming that proxy.mycompany.com
on port 8080
is also an HTTPS proxy
I suggest you fetch the content using apache http commons httpclient . There you can set proxy authentication on the client without the need to modify the global jvm properties.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.