Exception in thread "main" java.net.SocketTimeoutException: connection time is disabled on java.net.DualStackPlainSocketImpl.waitForConnect (native method)

I try to use Jsoup to connect to the site, but I keep getting the following error, I configured everything well inside the following xmls: "settings.xlm" and "pom.xml". can someone help me find out what is the root cause of all this. Than you are so strong.

here is the error that im is getting:

Exception in thread "main" java.net.SocketTimeoutException: connect timed out at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method) at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:75) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:157) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391) at java.net.Socket.connect(Socket.java:579) at sun.net.NetworkClient.doConnect(NetworkClient.java:175) at sun.net.www.http.HttpClient.openServer(HttpClient.java:378) at sun.net.www.http.HttpClient.openServer(HttpClient.java:473) at sun.net.www.http.HttpClient.<init>(HttpClient.java:203) at sun.net.www.http.HttpClient.New(HttpClient.java:290) at sun.net.www.http.HttpClient.New(HttpClient.java:306) at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:995) at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:931) at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:849) at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:425) at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:410) at org.jsoup.helper.HttpConnection.execute(HttpConnection.java:164) at org.jsoup.helper.HttpConnection.get(HttpConnection.java:153) at com.mycompany.mavenproject1.Facebook.main(Facebook.java:23) ------------------------------------------------------------------------ BUILD FAILURE ------------------------------------------------------------------------ Total time: 16.904s Finished at: Mon May 20 14:00:03 CAT 2013 Final Memory: 19M/47M ------------------------------------------------------------------------ Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default-cli) on project mavenproject1: Command execution failed. Process exited with an error: 1 (Exit value: 1) -> [Help 1] 
+4
source share
2 answers

You probably cannot access the Internet because you are behind a proxy server.

The proxy setting for Jsoup is the same as for regular connection URL in Java .

Given that your proxy server is at 127.0.0.1 and its port is 8182 , you can set it as:

 System.setProperty("http.proxyHost", "127.0.0.1"); System.setProperty("http.proxyPort", "8182"); 

If you are trying to access via HTTPS, then the properties are https.proxyHost and https.proxyPort .

See a working example:

 import org.jsoup.Jsoup; import org.jsoup.nodes.Document; public class ExampleJSoupProxy { public static void main(String[] args) throws Exception { System.setProperty("http.proxyHost", "127.0.0.1"); System.setProperty("http.proxyPort", "8182"); Document doc = Jsoup.connect("http://stackoverflow.com").get(); System.out.println("Obtained Title: " + doc.title()); } } 

Output:

 Obtained Title: Stack Overflow 
+7
source

This does not seem to be a problem in your application. This must be a network issue.

Check if you can open the page that you are trying to analyze in your browser. If you are using a proxy server, try running the application without a proxy server and find out if it solves the problem.

+1
source

Source: https://habr.com/ru/post/1481750/


All Articles