堆栈跟踪:
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时,它说在代码的最后一行之后重新设置连接。
我得到了这个错误即使我
请帮帮忙
以下是代码:
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();
}
发布于 2021-11-20 22:12:19
这个错误信息..。
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,如下所示:
因此,你可以看到:
WARNING: Unable to find an exact match for CDP version 96, so returning the closest version found: 95
解决方案
确保:
发布于 2021-11-20 05:38:52
当客户端在通过套接字返回响应之前关闭套接字连接时,此SocketException发生在服务器端。例如,在检索回复之前退出浏览器。
discord.com使用Websocket通信,当您连接时,wss://remote-auth-gateway.discord.gg/?v=1
正在等待认证。(套接字还活着)
也许driver.close()
关闭了插座。
https://stackoverflow.com/questions/70043181
复制相似问题