首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Selenium Connection Reset:无法找到CDP版本96的精确匹配,因此返回找到的最接近的版本: 95

Selenium Connection Reset:无法找到CDP版本96的精确匹配,因此返回找到的最接近的版本: 95
EN

Stack Overflow用户
提问于 2021-11-20 04:11:41
回答 2查看 5.5K关注 0票数 3

堆栈跟踪:

代码语言:javascript
运行
复制
Starting ChromeDriver 96.0.4664.45 (76e4c1bb2ab4671b8beba3444e61c0f17584b2fc-refs/branch-heads/4664@{#947}) on port 58050
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
Nov 20, 2021 9:34:48 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
Nov 20, 2021 9:34:49 AM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch
WARNING: Unable to find an exact match for CDP version 96, so returning the closest version found: 95
Nov 20, 2021 9:34:49 AM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch
INFO: Found CDP implementation for version 96 of 95
Nov 20, 2021 9:36:34 AM org.openqa.selenium.remote.http.WebSocket$Listener onError
WARNING: Connection reset
java.net.SocketException: Connection reset
    at java.base/sun.nio.ch.SocketChannelImpl.throwConnectionReset(SocketChannelImpl.java:394)
    at java.base/sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:426)
    at io.netty.buffer.PooledByteBuf.setBytes(PooledByteBuf.java:253)
    at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1132)
    at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:350)
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:151)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:719)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:655)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:581)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)
    at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
    at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.base/java.lang.Thread.run(Thread.java:831)

我正在制作一个java selenium bot,当我启动bot时,它说在代码的最后一行之后重新设置连接。

我得到了这个错误即使我

  • Chrome版本= 96
  • 驱动程序版本= 96

请帮帮忙

以下是代码:

代码语言:javascript
运行
复制
public static void main(String[] args) throws InterruptedException {
        //region GUI
        int loginTimeOutDuration = 100000;
        int chatLoadingDelay = 1000;
        String serverID = "707324806856572949";
        String message = "Hi!";
        //endregion

        System.setProperty
                ("webdriver.chrome.driver","C:\\\\Users\\\\~~~~~\\\\Downloads\\\\chromedriver.exe");
        WebDriver driver = new ChromeDriver();

        String baseUrl = "https://discord.com/channels/" + serverID + "/";

        driver.get(baseUrl);
        Thread.sleep(loginTimeOutDuration);
        WebElement element = driver.findElement(By.xpath("/html/body/div[1]/div[2]/div/div[2]/div/div/div/" +
                "div/div[2]/div[2]/div/aside/div/div/div[2]/div/div[2]/div[1]"));

        Actions actions = new Actions(driver);
        actions.contextClick(element).perform();
        driver.findElement(By.xpath("/html/body/div[1]/div[5]/div/div/div/div[1]/div[2]")).click();

        driver.close();
    }
EN

回答 2

Stack Overflow用户

发布于 2021-11-20 22:12:19

这个错误信息..。

代码语言:javascript
运行
复制
Nov 20, 2021 9:34:49 AM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch
WARNING: Unable to find an exact match for CDP version 96, so returning the closest version found: 95
Nov 20, 2021 9:34:49 AM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch
INFO: Found CDP implementation for version 96 of 95
Nov 20, 2021 9:36:34 AM org.openqa.selenium.remote.http.WebSocket$Listener onError
WARNING: Connection reset
java.net.SocketException: Connection reset

...implies表示ChromeDriver无法启动/生成一个新的浏览上下文,即ChromeDriver会话和java.net.SocketException: Connection reset

您的主要问题是您正在使用的二进制文件的版本之间的incompatibility,如下所示:

  • 支持的CDP版本: 85,93,94,95

因此,你可以看到:

代码语言:javascript
运行
复制
WARNING: Unable to find an exact match for CDP version 96, so returning the closest version found: 95

解决方案

确保:

  • Selenium被升级到当前的v4.1.0,其中:

  • 支持的CDP版本: 85,94,95,96
票数 2
EN

Stack Overflow用户

发布于 2021-11-20 05:38:52

当客户端在通过套接字返回响应之前关闭套接字连接时,此SocketException发生在服务器端。例如,在检索回复之前退出浏览器。

discord.com使用Websocket通信,当您连接时,wss://remote-auth-gateway.discord.gg/?v=1正在等待认证。(套接字还活着)

也许driver.close()关闭了插座。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70043181

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档