Java:使用htmlunit拒绝访问网站

我正在尝试使用Htmlunit / webclient等访问虚拟机上的网页 . 我的代码暂时正在执行此操作 .

当我运行该程序时,我收到以下错误:

线程“main”中的异常org.apache.http.conn.HttpHostConnectException:在org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:158)拒绝与https://www.google.com的连接在org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:149)在org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:121)在org.apache.http.impl .client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:573)在org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:425)在org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient的.java:820)在org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:776)在com.gargoylesoftware.htmlunit.HttpWebConnection.getResponse(HttpWebConnection.java:152)在com.gargoylesoftware.htmlunit . WebClient.loadWebResponseFromWebConnection(WebClient.java:1439)at com.gargoylesoftware.htmlun it.WebClient.loadWebResponse(WebClient.java:1358)在com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:307)在com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:373)在com.gargoylesoftware autoPEC.main中的.htmlunit.WebClient.getPage(WebClient.java:358)(autoPEC.java:7)引起:java.net.ConnectException:连接超时:连接java.net.DualStackPlainSocketImpl.connect0(本机方法)在java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)在java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)在java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)在java.net . AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)在java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)在java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)在java.net.Socket.connect(插座.java:589)在org.apach的sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:649) e.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:375)at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:148)... 13更多

Problem :当我在笔记本电脑上(在虚拟机之外)的eclipse上运行相同的代码时,代码运行正常,没有任何错误 .

任何人都可以解释为什么我在虚拟机上得到这个?因为代码似乎很好 . 是否有一些安全措施阻止我的VM上的IDE访问该网站或其他东西?我的防病毒软件?

How can I access a website on my Virtual Machine just the way I am accessing it outside the VM?

回答(0)