You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Jenkins运行自动化测试时WebDriverManager报Connection reset异常

Jenkins中WebDriverManager连接重置异常排查与解决

问题背景

已在Jenkins中手动配置chromedriver.exe,自动化测试运行正常,但改用WebDriverManager管理驱动时抛出连接重置异常。

异常信息

17:32:12 io.github.bonigarcia.wdm.config.WebDriverManagerException: java.net.SocketException: Connection reset
17:32:12    at io.github.bonigarcia.wdm.WebDriverManager.handleException(WebDriverManager.java:1414)
17:32:12    at io.github.bonigarcia.wdm.WebDriverManager.manage(WebDriverManager.java:1189)
17:32:12    at io.github.bonigarcia.wdm.WebDriverManager.fallback(WebDriverManager.java:1430)
17:32:12    at io.github.bonigarcia.wdm.WebDriverManager.handleException(WebDriverManager.java:1408)
17:32:12    at io.github.bonigarcia.wdm.WebDriverManager.manage(WebDriverManager.java:1189)
17:32:12    at io.github.bonigarcia.wdm.WebDriverManager.setup(WebDriverManager.java:426)
17:32:12    at com.AT.base.WebDriverFactory.createFirefoxProfile(WebDriverFactory.java:141)
17:32:12    at com.AT.base.WebDriverFactory.createInstance(WebDriverFactory.java:62)
17:32:12    at com.AT.base.BaseTest.setupWebDriver(BaseTest.java:253)
17:32:12    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
17:32:12    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
17:32:12    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
17:32:12    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
17:32:12    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:133)
17:32:12    at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:62)
17:32:12    at org.testng.internal.ConfigInvoker.invokeConfigurationMethod(ConfigInvoker.java:340)
17:32:12    at org.testng.internal.ConfigInvoker.invokeConfigurations(ConfigInvoker.java:294)
17:32:12    at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:176)
17:32:12    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:122)
17:32:12    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
17:32:12    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
17:32:12    at java.base/java.lang.Thread.run(Thread.java:834)
17:32:12 Caused by: java.net.SocketException: Connection reset
17:32:13    at java.base/java.net.SocketInputStream.read(SocketInputStream.java:186)
17:32:13    at java.base/java.net.SocketInputStream.read(SocketInputStream.java:140)
17:32:13    at java.base/sun.security.ssl.SSLSocketInputRecord.read(SSLSocketInputRecord.java:484)
17:32:13    at java.base/sun.security.ssl.SSLSocketInputRecord.readHeader(SSLSocketInputRecord.java:478)
17:32:13    at java.base/sun.security.ssl.SSLSocketInputRecord.decode(SSLSocketInputRecord.java:160)
17:32:13    at java.base/sun.security.ssl.SSLTransport.decode(SSLTransport.java:111)
17:32:13    at java.base/sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1383)
17:32:13    at java.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1296)
17:32:13    at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:416)
17:32:13    at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:388)
17:32:13    at org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory.executeHandshake(SSLConnectionSocketFactory.java:303)
17:32:13    at org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:275)
17:32:13    at org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:251)
17:32:13    at org.apache.hc.client5.http.impl.io.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:181)
17:32:13    at org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:447)
17:32:13    at org.apache.hc.client5.http.impl.classic.InternalExecRuntime.connectEndpoint(InternalExecRuntime.java:162)
17:32:13    at org.apache.hc.client5.http.impl.classic.InternalExecRuntime.connectEndpoint(InternalExecRuntime.java:172)
17:32:13    at org.apache.hc.client5.http.impl.classic.ConnectExec.execute(ConnectExec.java:142)
17:32:13    at org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
17:32:13    at org.apache.hc.client5.http.impl.classic.ProtocolExec.execute(ProtocolExec.java:192)
17:32:13    at org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
17:32:13    at org.apache.hc.client5.http.impl.classic.HttpRequestRetryExec.execute(HttpRequestRetryExec.java:96)
17:32:13    at org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
17:32:13    at org.apache.hc.client5.http.impl.classic.ContentCompressionExec.execute(ContentCompressionExec.java:152)
17:32:13    at org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
17:32:13    at org.apache.hc.client5.http.impl.classic.RedirectExec.execute(RedirectExec.java:115)
17:32:13    at org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
17:32:13    at org.apache.hc.client5.http.impl.classic.InternalHttpClient.doExecute(InternalHttpClient.java:170)
17:32:13    at org.apache.hc.client5.http.impl.classic.CloseableHttpClient.execute(CloseableHttpClient.java:87)
17:32:13    at org.apache.hc.client5.http.impl.classic.CloseableHttpClient.execute(CloseableHttpClient.java:55)
17:32:13    at org.apache.hc.client5.http.classic.HttpClient.executeOpen(HttpClient.java:183)
17:32:13    at io.github.bonigarcia.wdm.online.HttpClient.execute(HttpClient.java:157)
17:32:13    at io.github.bonigarcia.wdm.online.Downloader.downloadAndExtract(Downloader.java:140)
17:32:13    at io.github.bonigarcia.wdm.online.Downloader.download(Downloader.java:92)
17:32:13    at io.github.bonigarcia.wdm.WebDriverManager.download(WebDriverManager.java:1272)
17:32:13    at io.github.bonigarcia.wdm.WebDriverManager.manage(WebDriverManager.java:1183)
17:32:13    ... 20 more

解决方案

1. 配置Jenkins代理

若Jenkins处于内网环境,给WebDriverManager设置代理参数:

WebDriverManager.chromedriver().proxy("http://your-proxy-host:port").setup();

或通过系统属性全局配置:

System.setProperty("wdm.proxyHost", "your-proxy-host");
System.setProperty("wdm.proxyPort", "port");

2. 强制使用本地驱动

利用已配置好的本地驱动,跳过自动下载:

// 指定驱动版本
WebDriverManager.chromedriver().useDriverVersion("对应版本号").setup();
// 或直接指定本地驱动路径
WebDriverManager.chromedriver().driverPath("path/to/chromedriver.exe").setup();

3. 检查网络与SSL配置

  • 确认Jenkins服务器能访问WebDriverManager默认下载源
  • 若存在SSL证书问题,临时禁用SSL验证(仅测试环境):
WebDriverManager.chromedriver().sslVerification(false).setup();

4. 更新WebDriverManager版本

旧版本可能存在网络兼容性问题,升级到最新稳定版:

<!-- Maven依赖示例 -->
<dependency>
    <groupId>io.github.bonigarcia</groupId>
    <artifactId>webdrivermanager</artifactId>
    <version>最新版本号</version>
</dependency>

内容的提问来源于stack exchange,提问作者mmhh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.19 06:05:54