I'm testing the work of proxy servers, connecting through them to different URLs. For example, proxy server 216.171.41.43:45554 (Socks5) for the following addresses:

  • https://google.com
  • https://youtube.com

at the moment of receiving the stream

 in = new BufferedReader(new InputStreamReader(conn.getInputStream())); 

falls out with an error

 java.net.SocketException: Connection reset 

and does not give any code page. With all this address:

  • https://ya.ru
  • https://www.yahoo.com/

work fine. By the way, if you specify https://yahoo.com/ (without www ) getting the stream will fall out with the same error.

The connection itself for all addresses passes almost at the first attempt:

 URLConnection conn = url.openConnection(new Proxy(Proxy.Type.SOCKS, new InetSocketAddress(ip, port))).connect(); 

Tell me, what could be the reason for such work of proxy servers? Why does it turn out to connect to the necessary resource, but I can't get the page code?


 try { URL url = new URL("https://www.yahoo.com/"); String ip = "216.171.41.43"; int port = 45554; URLConnection conn = url.openConnection(new Proxy(Proxy.Type.SOCKS, new InetSocketAddress(ip, port))); conn.setConnectTimeout(2000); BufferedReader in = null; while (true) { try { conn.connect(); in = new BufferedReader(new InputStreamReader(conn.getInputStream())); break; } catch (Exception e) { e.printStackTrace(); } } } 

Mistake:

 java.net.SocketException: Connection reset at java.net.SocketInputStream.read(SocketInputStream.java:209) at java.net.SocketInputStream.read(SocketInputStream.java:141) at sun.security.ssl.InputRecord.readFully(InputRecord.java:465) at sun.security.ssl.InputRecord.read(InputRecord.java:503) at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:973) at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375) at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1403) at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1387) at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:559) at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185) at sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:153) 
  • Because the proxy server is so configured, for example. - Roman
  • @Roman There was a thought that the address of the proxy server is in the "black list" of the resource, now came to the conclusion that this is not the case. How can you understand in advance whether a proxy server is suitable for accessing a resource? What could be the setting you are talking about? - Alexey

0