I'm trying to make an https connection:
public static void main(String[] args) throws UnknownHostException, IOException {
/*None of these worked:
System.setProperty("http.proxyHost", "prxgm.aknet.akb");
System.setProperty("http.proxyPort", "8080");
System.setProperty("https.proxyHost", "prxgm.aknet.akb");
System.setProperty("https.proxyPort", "8080");
System.setProperty("java.net.useSystemProxies", "true");
*/
/*neither this helped:
ProxySearch proxySearch = new ProxySearch();
proxySearch.addStrategy(Strategy.OS_DEFAULT);
ProxySelector proxySelector = proxySearch.getProxySelector();
ProxySelector.setDefault(proxySelector);
*/
String host = //"services.gradle.org"
"www.yapikredi.com.tr"
;
Integer port = 443;
SSLSocketFactory sslsocketfactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
SSLSocket sslsocket = (SSLSocket) sslsocketfactory
.createSocket(host, port);
InputStream in = sslsocket.getInputStream();
OutputStream out = sslsocket.getOutputStream();
out.write(1);
while (in.available() > 0) {
System.out.print(in.read());
}
System.out.println("Secured connection performed successfully");
}
I get this exception:
Exception in thread "main" java.net.ConnectException: Connection timed out: connect
at java.base/sun.nio.ch.Net.connect0(Native Method)
at java.base/sun.nio.ch.Net.connect(Net.java:579)
at java.base/sun.nio.ch.Net.connect(Net.java:568)
at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:576)
at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:327)
at java.base/java.net.Socket.connect(Socket.java:666)
at java.base/sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:304)
at java.base/sun.security.ssl.SSLSocketImpl.<init>(SSLSocketImpl.java:163)
at java.base/sun.security.ssl.SSLSocketFactoryImpl.createSocket(SSLSocketFactoryImpl.java:88)
at SSLDeneme.main(SSLDeneme.java:25)
I can open https://www.yapikredi.com.tr in my browser, so I think Java proxy settings are not correct.
This I've tried these without luck so far:
- Set proxy settings using Run Configuration in eclipse: -Dhttp.proxyHost=prxgm.aknet.akb -Dhttp.proxyPort=8080 -Dhttps.proxyHost=prxgm.aknet.akb -Dhttps.proxyPort=8080
- Set proxy settings from the Java code as commented out in the code above.
tracert www.yapikredi.com.tr prints:
Tracing route to www.yapikredi.com.tr [193.254.228.224] over a maximum of 30 hops:
1 <1 ms <1 ms <1 ms 10.215.144.1
2 1 ms <1 ms <1 ms 10.215.252.3
3 1 ms <1 ms <1 ms 10.243.226.61
4 * * * Request timed out.
5 * * * Request timed out.
6 * * * Request timed out.
7 * * * Request timed out.
8 * * * Request timed out.
9 * * * Request timed out.
10 * * * Request timed out.
11 * * * Request timed out.
12 * * * Request timed out.
13 * * * Request timed out.
14 * * * Request timed out.
15 * * * Request timed out.
16 * * * Request timed out.
17 * * * Request timed out.
18 * * * Request timed out.
19 * * * Request timed out.
20 * * * Request timed out.
21 * * * Request timed out.
22 * * * Request timed out.
23 * * * Request timed out.
24 * * * Request timed out.
25 * * * Request timed out.
26 * * * Request timed out.
27 * * * Request timed out.
28 * * * Request timed out.
29 * * * Request timed out.
30 * * * Request timed out.
Trace complete.
ping to destination time outs (ping may be disabled in our system):
ping www.yapikredi.com.tr
Pinging www.yapikredi.com.tr [193.254.228.224] with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Ping statistics for 193.254.228.224:
Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
- telnet www.yapikredi.com.tr times out.
- The code above, and all telnet tracert etc checks work ok for an address that by-passes proxy (a.k.a. https://www.akbank.com)
- Proxy-Vole library suggested here didn't help either.
What else can I check?