Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Net::ReadTimeout: Net::ReadTimeout with #<TCPSocket:(closed)> #7563

Closed
yegor256 opened this issue Sep 13, 2019 · 12 comments
Closed

Net::ReadTimeout: Net::ReadTimeout with #<TCPSocket:(closed)> #7563

yegor256 opened this issue Sep 13, 2019 · 12 comments

Comments

@yegor256
Copy link

I'm getting this exception very often when the server is pretty loaded:

Net::ReadTimeout: Net::ReadTimeout with #<TCPSocket:(closed)>
	/usr/lib/ruby/2.6.0/net/protocol.rb:217:in `rbuf_fill'
	/usr/lib/ruby/2.6.0/net/protocol.rb:191:in `readuntil'
	/usr/lib/ruby/2.6.0/net/protocol.rb:201:in `readline'
	/usr/lib/ruby/2.6.0/net/http/response.rb:40:in `read_status_line'
	/usr/lib/ruby/2.6.0/net/http/response.rb:29:in `read_new'
	/usr/lib/ruby/2.6.0/net/http.rb:1509:in `block in transport_request'
	/usr/lib/ruby/2.6.0/net/http.rb:1506:in `catch'
	/usr/lib/ruby/2.6.0/net/http.rb:1506:in `transport_request'
	/usr/lib/ruby/2.6.0/net/http.rb:1479:in `request'
	/var/lib/gems/2.6.0/gems/selenium-webdriver-3.142.3/lib/selenium/webdriver/remote/http/default.rb:129:in `response_for'
	/var/lib/gems/2.6.0/gems/selenium-webdriver-3.142.3/lib/selenium/webdriver/remote/http/default.rb:82:in `request'
	/var/lib/gems/2.6.0/gems/selenium-webdriver-3.142.3/lib/selenium/webdriver/remote/http/common.rb:64:in `call'
	/var/lib/gems/2.6.0/gems/selenium-webdriver-3.142.3/lib/selenium/webdriver/remote/bridge.rb:167:in `execute'
	/var/lib/gems/2.6.0/gems/selenium-webdriver-3.142.3/lib/selenium/webdriver/remote/w3c/bridge.rb:567:in `execute'
	/var/lib/gems/2.6.0/gems/selenium-webdriver-3.142.3/lib/selenium/webdriver/remote/w3c/bridge.rb:59:in `get'
	/var/lib/gems/2.6.0/gems/selenium-webdriver-3.142.3/lib/selenium/webdriver/common/navigation.rb:32:in `to'

It seems that it would make sense to catch Net::ReadTimeout and retry, just like you are catching similar exceptions, in http/default.rb.

@p0deje
Copy link
Member

p0deje commented Sep 16, 2019

Is your server page loads for more than 60 seconds? If yes, then you just need to increase the timeout - https://github.com/SeleniumHQ/selenium/wiki/Ruby-Bindings#internal-timeouts

@Rajagopalan-M
Copy link

@p0deje

But it should have been like one has to set the value here

driver.manage.timeouts.page_load=

not like this

client = Selenium::WebDriver::Remote::Http::Default.new
client.read_timeout = 120

That's the way Java binding works. But here in ruby selenium binding page_load= timings works only for goto method.

@p0deje
Copy link
Member

p0deje commented Dec 1, 2019

@Rajagopalan-M That's how specification defines page load timeout:

Provides the timeout limit used to interrupt an explicit navigation attempt.

For navigation triggered by element clicks, it should be ignored.

@Rajagopalan-M
Copy link

@p0deje
Okay,but In Java Binding, page_load is used for the page load as a result of element click as well.

@p0deje
Copy link
Member

p0deje commented Dec 1, 2019

You are right, in Java this works the same way. I even found a test for that. However, both Java and Ruby does the same thing when setting timeout, so I guess in Ruby you should also be able to just do the following and avoid timeout errors:

driver.manage.timeouts.page_load = 120

@Rajagopalan-M
Copy link

Rajagopalan-M commented Dec 1, 2019

@p0deje

However, both Java and Ruby does the same thing when setting timeout

I am not sure whether I misunderstood you.

driver.manage.timeouts.page_load = 120

The above line not doing the same thing. If you set page_load in Java, it's used for loading the page as a result of loading the url by driver.navigate().To and also the page loading as a result of clicking the button but in ruby if you set page_load then it is only used Page loading as a result of goto.

@p0deje
Copy link
Member

p0deje commented Dec 1, 2019

The above line not doing the same thing. If you set page_load in Java, it's used for loading the page as a result of loading the url by driver.navigate().To and also the page loading as a result of clicking the button but in ruby if you set page_load then it is only used Page loading as a result of goto.

Hm, it should work the same way. If it is not, can you create a bug report with the test case on how to reproduce?

@Rajagopalan-M
Copy link

@p0deje

Okay, I will do it tomorrow morning. Thank you very much.

@Rajagopalan-M
Copy link

Rajagopalan-M commented Dec 2, 2019

@p0deje

I don't have site which loads more than 3 seconds after a button click. I have one but that's my internal site. So use any site in the given below program and you can clearly see button click throws the time out error after 3 seconds. And I reduced this timeout to 3 seconds for you to notice the fact that setting up page load driver.manage().timeouts().pageLoadTimeout(3L, TimeUnit.SECONDS); infact involves in button click as well

Here is my program


import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

import java.util.concurrent.TimeUnit;

public class Gopal {
    public static void main(String args[]) {
        WebDriver driver = new ChromeDriver();
        System.setProperty("webdriver.chrome.driver", "C:\\Ruby26\\bin\\chromedriver.exe");
        driver.navigate().to("Your Url");
        driver.manage().timeouts().pageLoadTimeout(3L, TimeUnit.SECONDS);
        driver.findElement(By.id("UserName")).clear();
        driver.findElement(By.id("UserName")).sendKeys("xxxx");
        driver.findElement((By.id("Password"))).clear();
        driver.findElement((By.id("Password"))).sendKeys("yyy");
        driver.findElement((By.id("Login"))).click();
    }
}

@p0deje
Copy link
Member

p0deje commented Dec 8, 2019

I've just added more tests for page load timeout in Ruby (81552aa) and both scenarios timeout properly:

  • navigation to a page that loads slowly (using driver.get)
  • navigation to a page that loads slowly (using driver.find_element(...).click)

@Rajagopalan-M If you can find a case when it doesn't work in Ruby that I can use to debug the issue, please create a new bug report.

@p0deje p0deje closed this as completed Dec 8, 2019
@Rajagopalan-M
Copy link

@p0deje Sure thank you very much . I will check and let you know.

@lock
Copy link

lock bot commented Jan 7, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Jan 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants