在代理 testng 中工作时返回连接超时
Posted
技术标签:
【中文标题】在代理 testng 中工作时返回连接超时【英文标题】:While working inside proxy testng returns connection timeout 【发布时间】:2021-03-20 20:04:29 【问题描述】:当我连接到 ***/代理时,Testng 在 intellij 中运行测试时返回以下错误:
org.testng.TestNGException: java.net.ConnectException: Connection timed out: connect
at org.testng.TestNG.parseSuite(TestNG.java:354)
at org.testng.TestNG.initializeSuitesAndJarFile(TestNG.java:374)
at com.intellij.rt.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:39)
at com.intellij.rt.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:109)
Caused by: 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:503)
at java.base/sun.nio.ch.Net.connect(Net.java:492)
at java.base/sun.nio.ch.NiosocketImpl.connect(NioSocketImpl.java:588)
at java.base/java.net.Socket.connect(Socket.java:648)
at java.base/java.net.Socket.connect(Socket.java:597)
at java.base/sun.net.NetworkClient.doConnect(NetworkClient.java:182)
at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:474)
at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:569)
at java.base/sun.net.www.http.HttpClient.<init>(HttpClient.java:242)
at java.base/sun.net.www.http.HttpClient.New(HttpClient.java:341)
at java.base/sun.net.www.http.HttpClient.New(HttpClient.java:362)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1261)
at
有什么想法可以为 testng 设置代理吗? 还是其他解决方案?
【问题讨论】:
【参考方案1】:要解决这个问题,你必须指定 VM 参数进行测试:
-Dhttp.proxyHost=your_host
-Dhttp.proxyPort=your_port
-Dhttps.proxyHost=your_host
-Dhttps.proxyPort=your_port
【讨论】:
以上是关于在代理 testng 中工作时返回连接超时的主要内容,如果未能解决你的问题,请参考以下文章