简体   繁体   English

如何修复 [警告]:连接到 Chrome 时超时,正在重试

[英]How to fix [WARNING]: Timed out connecting to Chrome, retrying

I access Websites in a loop via selenium Java based.我通过基于 selenium Java 的循环访问网站。 Some of the sites crash imediately so that i get the error一些网站立即崩溃,所以我得到了错误

[1618982990.911][WARNING]: Timed out connecting to Chrome, retrying...

after a short time.片刻之后。

So this is not a selenium issue i assume, since even chrome crashes if i visit the site manually because of js errors, saying unresonsive Website所以这不是我假设的 selenium 问题,因为如果我因为 js 错误而手动访问该网站,甚至 chrome 也会崩溃,说网站不合理

My problem is, that every time a site crashes, chromedriver and a chrome instance will stay alive so that i have high CPU usage after a short time.我的问题是,每次网站崩溃时,chromedriver 和 chrome 实例都会保持活动状态,这样我在短时间内就会有很高的 CPU 使用率。

Can i tell selenium to quit the instance if it is frozen?如果实例被冻结,我可以告诉 selenium 退出实例吗? But i dont know how this should be possible if it does not get answer from chrome anymore?但我不知道如果它不再从 chrome 得到答案,这应该怎么可能?

Thankful for any solution or idea感谢任何解决方案或想法

Sometimes with some Windows version driver.quit() will not kill the chrome process which I have come across.有时使用一些 Windows 版本 driver.quit() 不会杀死我遇到的 chrome 进程。 So at the end of the script you can kill the chrome processes if exists using java code, if the driver.quit doesn't work.因此,在脚本结束时,如果 driver.quit 不起作用,您可以使用 java 代码终止 chrome 进程。

Please refer stackoverflow link which has the code to kill the process if exists in Java and pass the chrome process to it.如果 Java 中存在终止进程的代码,请参考stackoverflow链接,并将 chrome 进程传递给它。

i found a workaround for anyone who would be interested.我为任何有兴趣的人找到了解决方法。 First setting up a pageLoadTimeout, after that force any chrome instance to be killed if an Exception is being thrown.首先设置一个 pageLoadTimeout,然后在抛出异常时强制终止任何 chrome 实例。

 try{
driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
//some excecution code....
}

catch (Exception e) {
        System.out.println("Error. Closing");
        driver.quit();
        Runtime.getRuntime().exec("taskkill /F /IM chrome.exe");}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何修复 [1573451709.039][警告]:连接到 Chrome 超时,正在重试...同时使用 chrome 版本 78 和 chrome 驱动程序版本 78.0.3904.70 - How to fix [1573451709.039][WARNING]: Timed out connecting to Chrome, retrying... while using chrome version 78 and chrome driver version 78.0.3904.70 通过 Selenium 使用 ChromeDriver 2.43 和 Chrome 连接到 Chrome 时超时,正在重试...错误 - Timed out connecting to Chrome, retrying… error using ChromeDriver 2.43 and Chrome through Selenium ChromeDriver。 连接到Chrome超时。 Linux Debian服务器 - ChromeDriver. Timed out connecting to Chrome. Linux debian server SocketTimeoutException:读取超时,如何解决? - SocketTimeoutException: Read timed out, how to fix it? 如何修复连接超时 - how to fix connection timed out in retrofit 如何修复翻新中超时的SSL握手 - How to fix SSL handshake timed out in Retrofit 如何修复“Futures 超时 [5 秒]”和 [akkaDeadLetter] 错误? - How can I fix "Futures timed out [5 seconds]" and [akkaDeadLetter] errors? 我如何解决此问题,mqtt Paho超时但未报告连接丢失 - How do I fix this issue mqtt Paho timed out but did not report as connection lost Java Lambda Function 在连接到 Informix DB 时超时 - Java Lambda Function is getting timed out while connecting to Informix DB Pitest警告:由于TIMED_OUT,从站异常退出 - Pitest WARNING : Slave exited abnormally due to TIMED_OUT
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM