Watir webdriver not working as expected - ruby

I tried to execute a simple browser test
require 'rubygems'
require 'watir-webdriver'
b = Watir::Browser.new :firefox
b.goto 'http://www.google.com/'
The browser launched and closed immediately throwing the following error
c:/ruby22/lib/ruby/2.2.0/net/http/generic_request.rb:25:in `initialize': HTTP request path is empty (ArgumentError)
from c:/ruby22/lib/ruby/2.2.0/net/http/request.rb:14:in `initialize'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/http/default.rb:95:in `new'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/http/default.rb:95:in `new_request_for'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/http/default.rb:57:in `request'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/http/default.rb:88:in `request'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/http/common.rb:59:in `call'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/bridge.rb:649:in `raw_execute'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/bridge.rb:123:in `create_session'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/bridge.rb:87:in `initialize'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/firefox/bridge.rb:55:in `initialize'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/common/driver.rb:53:in `new'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/common/driver.rb:53:in `for'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver.rb:84:in `for'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/watir-webdriver-0.9.1/lib/watir-webdriver/browser.rb:46:in `initialize'
from test.rb:3:in `new'
from test.rb:3:in `<main>'
HTTP request path is empty means what? is the calling parameters changed in new versions of watir?
Anyone faced similar problem?
My System is Windows 7 64 bit, I am running behind a proxy, the browser already configured with a proxy
---EDIT---
I have introduced a trailing slash, but I am getting a new error now and also getting the previous error, every time I have to change the code and save it to get this error
c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/firefox/launcher.rb:90:in `connect_until_stable': unable to obtain stable firefox connection in 60 seconds (127.0.0.1:7055) (Selenium::WebDriver::Error::WebDriverError)
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/firefox/launcher.rb:55:in `block in launch'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/common/socket_lock.rb:43:in `locked'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/firefox/launcher.rb:51:in `launch'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/firefox/bridge.rb:43:in `initialize'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/common/driver.rb:53:in `new'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/common/driver.rb:53:in `for'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver.rb:84:in `for'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/watir-webdriver-0.9.1/lib/watir-webdriver/browser.rb:46:in `initialize'
from test.rb:8:in `new'
from test.rb:8:in `<main>'
---EDIT---
I have downloaded the geckodriver v0.10.0 from https://github.com/mozilla/geckodriver/releases and copy pasted the geckodriver.exe in to the firefox folder and also added the firefox folder to the PATH
I installed the selenium-webdriver beta version 3.0.0.beta2.1
But still I am getting the same error
c:/ruby22/lib/ruby/2.2.0/net/http/generic_request.rb:25:in `initialize': HTTP request path is empty (ArgumentError)
I have also tried installing the Firefox ESR version and added to PATH which is also not working
---EDIT---
I opened the file c:/ruby22/lib/ruby/2.2.0/net/http/generic_request.rb
and introduced print statement as follows
print "\n"
print uri_or_path
if URI === uri_or_path then
print "\ncoming to if part\n"
#uri = uri_or_path.dup
host = #uri.hostname.dup
host << ":".freeze << #uri.port.to_s if #uri.port != #uri.default_port
#path = uri_or_path.request_uri
raise ArgumentError, "no HTTP request path given" unless #path
else
print "\ncoming to else part\n"
#uri = nil
host = nil
raise ArgumentError, "no HTTP request path given" unless uri_or_path
raise ArgumentError, "HTTP request path is empty" if uri_or_path.empty?
#path = uri_or_path.dup
end
And I got the below output
/session
coming to else part
coming to else part
/shutdown
coming to else part
c:/ruby22/lib/ruby/2.2.0/net/http/generic_request.rb:29:in `initialize': HTTP request path is empty (ArgumentError)

Try entering those commands in IRB, a line at a time. that will make it clearer where the failure is occuring
Your initial error indicated it was failing on line 3,which in your code above is where it tries to create a new instance of a browser object (which also launches firefox, and then tries to connect the browser object to the actual browser). If that's not working it's usually because you are not using a version of webdriver that supports your browser. Perhaps you have a brand new firefox, and need to update webdriver.
Sometimes there is a brief window after a new FF comes out (every 6 weeks) that introduced a breaking change, where we don't have an updated webdriver gem that supports that version.

Most likely you were seeing this due to a bug in Firefox 47.0. You need to update to Firefox 47.0.1 for it to work with Selenium 2.53.4.

Related

Viewport not connecting in Ubuntu Server VM

I am migrating a Redmine plugin that implements user authentication via EWS. The plugin was tested on Redmine v4.x running on an Ubuntu Desktop VM and was working correctly (could tell if the given credentials were valid or not).
The main part of the plugin is:
require 'viewpoint'
include Viewpoint::EWS
defaultServer = 'https://company.mail.server/ews/exchange.asmx'
defaultEmailDomain = '#domain.com'
emailAddress = "username" + defaultEmailDomain
password = "password"
client = Viewpoint::EWSClient.new(defaultServer, emailAddress, password)
result = client
begin
client.folders
rescue
result = 'nope'
end
puts result
This code works on both the previous VM and my Windows machine, but on my new Ubuntu Server 22.04 VM returns 'nope'.
I also tried to write a version in Python using exchangelib, which worked on the new VM. IMO that indicates that the problem is not related to any network constrictions Ubuntu Server might have.
Any suggestions?
Update:
Following Richard's suggestion I saved the error message captured by rescue. After changing the error type to EwsError, I got the following:
/usr/lib/ruby/3.0.0/openssl/digest.rb:35:in `initialize': Digest initialization failed: initialization error (OpenSSL::Digest::DigestError)
from /usr/lib/ruby/3.0.0/openssl/digest.rb:35:in `block (3 levels) in <class:Digest>'
from /usr/lib/ruby/3.0.0/openssl/digest.rb:41:in `new'
from /usr/lib/ruby/3.0.0/openssl/digest.rb:41:in `block (3 levels) in <class:Digest>'
from /var/lib/gems/3.0.0/gems/rubyntlm-0.6.3/lib/net/ntlm.rb:149:in `ntlm_hash'
from /var/lib/gems/3.0.0/gems/rubyntlm-0.6.3/lib/net/ntlm.rb:162:in `ntlmv2_hash'
from /var/lib/gems/3.0.0/gems/rubyntlm-0.6.3/lib/net/ntlm/message/type2.rb:73:in `response'
from /var/lib/gems/3.0.0/gems/httpclient-2.8.3/lib/httpclient/auth.rb:563:in `block in get'
from /usr/lib/ruby/3.0.0/mutex_m.rb:78:in `synchronize'
from /usr/lib/ruby/3.0.0/mutex_m.rb:78:in `mu_synchronize'
from /var/lib/gems/3.0.0/gems/httpclient-2.8.3/lib/httpclient/auth.rb:537:in `get'
from /var/lib/gems/3.0.0/gems/httpclient-2.8.3/lib/httpclient/auth.rb:97:in `block in filter_request'
from /var/lib/gems/3.0.0/gems/httpclient-2.8.3/lib/httpclient/auth.rb:95:in `each'
from /var/lib/gems/3.0.0/gems/httpclient-2.8.3/lib/httpclient/auth.rb:95:in `filter_request'
from /var/lib/gems/3.0.0/gems/httpclient-2.8.3/lib/httpclient.rb:1231:in `block in do_get_block'
from /var/lib/gems/3.0.0/gems/httpclient-2.8.3/lib/httpclient.rb:1230:in `each'
from /var/lib/gems/3.0.0/gems/httpclient-2.8.3/lib/httpclient.rb:1230:in `do_get_block'
from /var/lib/gems/3.0.0/gems/httpclient-2.8.3/lib/httpclient.rb:1019:in `block in do_request'
from /var/lib/gems/3.0.0/gems/httpclient-2.8.3/lib/httpclient.rb:1133:in `protect_keep_alive_disconnected'
from /var/lib/gems/3.0.0/gems/httpclient-2.8.3/lib/httpclient.rb:1014:in `do_request'
from /var/lib/gems/3.0.0/gems/httpclient-2.8.3/lib/httpclient.rb:856:in `request'
from /var/lib/gems/3.0.0/gems/httpclient-2.8.3/lib/httpclient.rb:765:in `post'
from /var/lib/gems/3.0.0/gems/viewpoint-1.1.1/lib/ews/connection.rb:103:in `post'
from /var/lib/gems/3.0.0/gems/viewpoint-1.1.1/lib/ews/connection.rb:81:in `dispatch'
from /var/lib/gems/3.0.0/gems/viewpoint-1.1.1/lib/ews/soap/exchange_web_service.rb:212:in `do_soap_request'
from /var/lib/gems/3.0.0/gems/viewpoint-1.1.1/lib/ews/soap/exchange_data_services.rb:503:in `find_folder'
from /var/lib/gems/3.0.0/gems/viewpoint-1.1.1/lib/ews/folder_accessors.rb:45:in `folders'
from /home/jdredd/auth_source_ews/app/models/test.rb:27:in `<main>'
Additional info: the Windows test machine, where the user authentication runs succesfully, has the same gem versions as above. The only difference is the verion of Ruby itself (3.0.2p107 on Ubuntu, 3.1.2p20 on Windows).
Update:
After modifying openssl.cnf according to this diff enabling loading legacy providers, the plugin works now.
Try investigating the error message.
begin
client.folders
rescue StandardError => err
puts err
result = 'nope'
end
https://thoughtbot.com/blog/rescue-standarderror-not-exception

Watir: get sometimes a Net::ReadTimeout error by launching chrome browser

I just use a watir script to download sequential status infos from a server. In most cases it works fine, but sometimes I get an Net::ReadTimeout error. I don't know why?
Code:
require "rubygems"
require "watir"
Watir.default_timeout = 180 # seconds – default is 60
prefs = { :download => { :prompt_for_download => false, :default_directory => path } }
browser = Watir::Browser.new :chrome, :switches => %w[--no-sandbox], :prefs => prefs
browser.goto 'https://www...'
...
Error Message:
/usr/lib/ruby/2.3.0/net/protocol.rb:158:in `rbuf_fill': Net::ReadTimeout (Net::ReadTimeout)
from /usr/lib/ruby/2.3.0/net/protocol.rb:136:in `readuntil'
from /usr/lib/ruby/2.3.0/net/protocol.rb:146:in `readline'
from /usr/lib/ruby/2.3.0/net/http/response.rb:40:in `read_status_line'
from /usr/lib/ruby/2.3.0/net/http/response.rb:29:in `read_new'
from /usr/lib/ruby/2.3.0/net/http.rb:1437:in `block in transport_request'
from /usr/lib/ruby/2.3.0/net/http.rb:1434:in `catch'
from /usr/lib/ruby/2.3.0/net/http.rb:1434:in `transport_request'from /usr/lib/ruby/2.3.0/net/http.rb:1407:in `request'
from /usr/lib/ruby/2.3.0/net/http.rb:1400:in `block in request'
from /usr/lib/ruby/2.3.0/net/http.rb:853:in `start'
from /usr/lib/ruby/2.3.0/net/http.rb:1398:in `request'
from /var/lib/gems/2.3.0/gems/selenium-webdriver-3.0.1/lib/selenium/webdriver/remote/http/default.rb:103:in `response_for'
from /var/lib/gems/2.3.0/gems/selenium-webdriver-3.0.1/lib/selenium/webdriver/remote/http/default.rb:57:in `request'
from /var/lib/gems/2.3.0/gems/selenium-webdriver-3.0.1/lib/selenium/webdriver/remote/http/common.rb:59:in `call'
from /var/lib/gems/2.3.0/gems/selenium-webdriver-3.0.1/lib/selenium/webdriver/remote/bridge.rb:653:in `raw_execute'
from /var/lib/gems/2.3.0/gems/selenium-webdriver-3.0.1/lib/selenium/webdriver/remote/bridge.rb:124:in `create_session'
from /var/lib/gems/2.3.0/gems/selenium-webdriver-3.0.1/lib/selenium/webdriver/remote/bridge.rb:88:in `initialize'
from /var/lib/gems/2.3.0/gems/selenium-webdriver-3.0.1/lib/selenium/webdriver/chrome/bridge.rb:41:in `initialize'
from /var/lib/gems/2.3.0/gems/selenium-webdriver-3.0.1/lib/selenium/webdriver/common/driver.rb:61:in `new'
from /var/lib/gems/2.3.0/gems/selenium-webdriver-3.0.1/lib/selenium/webdriver/common/driver.rb:61:in `for'
from /var/lib/gems/2.3.0/gems/selenium-webdriver-3.0.1/lib/selenium/webdriver.rb:82:in `for'
from /var/lib/gems/2.3.0/gems/watir-6.0.2/lib/watir/browser.rb:46:in `initialize'
from /var/www/jobs/ubuntu.rb:110:in `new'from /var/www/jobs/ubuntu.rb:5:in `<main>'
I just looking for a reason on this?
Is it possible the customize the settings on firefox? What is wrong?
Watir Version: 6.0.2
Selenium Version: 3.0.1
Browser Chrome Version: 57.0.2987.110
Chrome Driver Version: 2.29.461571
OS Version: Ubuntu 16.04.3 LTS
I had a similar problem when running my Selenium Webdriver tests on our Ubuntu Jenkins build server, but I never experienced this locally on my Windows PC. Like your problem, it was an intermittent issue. I spent quite a lot of time researching it and couldn't get to the bottom of it, I did however put it down to a Ruby/ Ubuntu issue rather than an issue with the test, because of this, I decided to rescue the Net::ReadTimeout error and retry. Since implementing the following example, I haven't experienced this problem again.
attempts = 0 # has to be outside the begin/rescue to avoid infinite loop
begin
profile = Selenium::WebDriver::Chrome::Profile.new
$driver = Selenium::WebDriver.for :chrome, :profile => profile,
$driver.manage.window.resize_to(1280, 720)
rescue Net::ReadTimeout => e
if attempts == 0
attempts += 1
retry
else
raise
end
end
You should be able to briefly modify the above example to work with Watir. It basically captures the error and retries/ re-runs the test.
First of all, Watir.default_timeout has nothing to do with error you have stated, So even if you increase the time of default_timeout, nothing would happen in this place, Watir.default_timeout is applicable only when you find an element, not for page_load.
Second off, this problem only exist in Ruby Selenium Binding, not in Java Selenium Binding, for an example, If you set
driver.manage.timeouts.page_load=120 (WATIR doesn't provide any systax to this selenium equivalent, so to write this code in WATIR, please invoke b.driver.)
This time settings is only applicable for goto method, it's not affecting anything when you click a button and waiting for a page load, the default timeout for page_load is 60 seconds, that would anyhow wait for 60 seconds, but what you set doesn't affect or change this 60 seconds. But this problem is not there for Selenium Java Binding, it's working properly.
Okay, the question is, you are using it for goto so why not you can use the page_load to set the time?
Actually you can decrease the time, but you can't increase the time beyond 60 seconds. But I found some workaround for this problem, but I strongly recommend you to file a bug in ruby selenium binding.
So it's not a WATIR problem, it's the problem in Ruby selenium binding.
Finally i tested also the solution with firefox and get the described error:
/var/lib/gems/2.1.0/gems/selenium-webdriver-3.0.1/lib/seleni‌​um/webdriver/remote/‌​response.rb:69:in 'assert_ok':
TypeError: Given platformVersion [object String] "any", but current platform version is [object String] "3.16.0-4-amd64"
(Selenium::WebDriver::Error::SessionNotCreatedError)
It seems to be a problem with a specific firefox and geckodriver version. I tested many combinations. This versions work without the TypeError:
Firefox 51.0.1
geckodriver 0.11.1
Thanks to dan.brown

connection closed by server error when getting accounts using coinbase-exchange websocket

I'm using the ruby coinbase-exchange gem, and I'm executing the code by copying and pasting it into irb.
This only happens when I'm running it as a websocket – when I just execute the code on its own, without the socket, it works fine.
When the following code executes,
accounts = Array.new(2, Array.new)
rest_api.accounts do |resp|
accounts = resp
end
this error is produced:
Coinbase::Exchange::APIError: GET https://api.exchange.coinbase.com/accounts?: connection closed by server
from /usr/local/lib/ruby/gems/2.3.0/gems/coinbase-exchange-0.1.2/lib/coinbase/exchange/adapters/em_http.rb:59:in `block in http_verb'
from /usr/local/lib/ruby/gems/2.3.0/gems/eventmachine-1.2.0.1/lib/em/deferrable.rb:158:in `set_deferred_status'
from /usr/local/lib/ruby/gems/2.3.0/gems/eventmachine-1.2.0.1/lib/em/deferrable.rb:198:in `fail'
from /usr/local/lib/ruby/gems/2.3.0/gems/em-http-request-1.1.5/lib/em-http/client.rb:123:in `on_error'
from /usr/local/lib/ruby/gems/2.3.0/gems/em-http-request-1.1.5/lib/em-http/client.rb:117:in `unbind'
from /usr/local/lib/ruby/gems/2.3.0/gems/em-http-request-1.1.5/lib/em-http/http_connection.rb:205:in `block in unbind'
from /usr/local/lib/ruby/gems/2.3.0/gems/em-http-request-1.1.5/lib/em-http/http_connection.rb:205:in `map'
from /usr/local/lib/ruby/gems/2.3.0/gems/em-http-request-1.1.5/lib/em-http/http_connection.rb:205:in `unbind'
from /usr/local/lib/ruby/gems/2.3.0/gems/em-http-request-1.1.5/lib/em-http/http_connection.rb:31:in `unbind'
from /usr/local/lib/ruby/gems/2.3.0/gems/eventmachine-1.2.0.1/lib/eventmachine.rb:1481:in `event_callback'
from /usr/local/lib/ruby/gems/2.3.0/gems/eventmachine-1.2.0.1/lib/eventmachine.rb:202:in `release_machine'
from /usr/local/lib/ruby/gems/2.3.0/gems/eventmachine-1.2.0.1/lib/eventmachine.rb:202:in `ensure in run'
from /usr/local/lib/ruby/gems/2.3.0/gems/eventmachine-1.2.0.1/lib/eventmachine.rb:205:in `run'
from (irb):79
from /usr/local/bin/irb:11:in `<main>'
What's the problem here? How do I get around it?

Selenium::Webdriver throwing wrong number of arguments error when used along with calabash

I try to launch a firefox browse while running calabash-ios scripts... but it throws following error:
#<ArgumentError: wrong number of arguments (0 for 1)>
/gems/ruby-1.9.3-p448/gems/calabash-cucumber-0.9.155/lib/calabash-cucumber/operations.rb:67:in `tap'
/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/rexml/parsers/baseparser.rb:183:in `pull'
/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/rexml/parsers/treeparser.rb:22:in `parse'
/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/rexml/document.rb:245:in `build'
/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/rexml/document.rb:43:in `initialize'
/gems/ruby-1.9.3-p448/gems/selenium-webdriver-2.35.1/lib/selenium/webdriver/firefox/extension.rb:44:in `new'
/gems/ruby-1.9.3-p448/gems/selenium-webdriver-2.35.1/lib/selenium/webdriver/firefox/extension.rb:44:in `read_id_from_install_rdf'
I can launch a firefox browser seperately without calabash-scripts.
How to overcome this problem?

Patching classes in Ruby's core lib

I'm trying to set the timeout for subsequent http calls to a very unreliable API. I tried multiple attempts at using Ruby's built-in Timeout.timeout() method but had had no such luck getting it to extend to sub calls. For example, Timeout.timeout(300) will set the first timeout to 300 but sub calls go back to 60. I added a print of the seconds_delay and here is what I saw:
[16:55:16 miker#laughwhat-lm ~/optisol/src/rails/tools_app/trunk/adhoc/ticket] $ bundle exec ruby buck.rb
300
nil
warning: peer certificate won't be verified in this SSL session
60
60
nil
warning: peer certificate won't be verified in this SSL session
60
Here is the error I receive with full stack trace:
[16:49:50 miker#laughwhat-lm ~/optisol/src/rails/tools_app/trunk/adhoc/ticket] $ bundle exec ruby buck.rb
warning: peer certificate won't be verified in this SSL session
warning: peer certificate won't be verified in this SSL session
warning: peer certificate won't be verified in this SSL session
warning: peer certificate won't be verified in this SSL session
warning: peer certificate won't be verified in this SSL session
warning: peer certificate won't be verified in this SSL session
warning: peer certificate won't be verified in this SSL session
/Users/miker/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/timeout.rb:64:in `rbuf_fill': execution expired (Timeout::Error)
from /Users/miker/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/net/protocol.rb:134:in `rbuf_fill'
from /Users/miker/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/net/protocol.rb:116:in `readuntil'
from /Users/miker/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/net/protocol.rb:126:in `readline'
from /Users/miker/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/net/http.rb:2028:in `read_status_line'
from /Users/miker/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/net/http.rb:2017:in `read_new'
from /Users/miker/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/net/http.rb:1051:in `request_without_fakeweb'
from /Users/miker/.rvm/gems/ree-1.8.7-2011.03/gems/fakeweb-1.3.0/lib/fake_web/ext/net_http.rb:50:in `request'
from /Users/miker/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/net/http.rb:845:in `post'
from /Users/miker/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/soap/netHttpClient.rb:93:in `post'
from /Users/miker/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/soap/netHttpClient.rb:116:in `start'
from /Users/miker/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/net/http.rb:543:in `start'
from /Users/miker/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/soap/netHttpClient.rb:115:in `start'
from /Users/miker/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/soap/netHttpClient.rb:92:in `post'
from /Users/miker/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/soap/streamHandler.rb:170:in `send_post'
from /Users/miker/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/soap/streamHandler.rb:109:in `send'
from /Users/miker/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/soap/rpc/proxy.rb:170:in `route'
from /Users/miker/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/soap/rpc/proxy.rb:141:in `call'
from /Users/miker/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/soap/rpc/driver.rb:178:in `call'
from /Users/miker/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/soap/rpc/driver.rb:232:in `getByBuyer'
from buck.rb:9
from /Users/miker/.rvm/gems/ree-1.8.7-2011.03/gems/yieldmanager-0.8.2/lib/yieldmanager/client.rb:131:in `session'
from buck.rb:8
from /Users/miker/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/timeout.rb:67:in `timeout'
from /Users/miker/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/timeout.rb:101:in `timeout'
from buck.rb:6
So I guess my question would be how can I go about patching the protocol.rb BufferedIO's method to look like this:
class BufferedIO
private
def rbuf_fill
puts "working"
timeout(300) { # forced 300 second timeout
#rbuf << #io.sysread(BUFSIZE)
}
end
end
Adding that to my ruby file before or after I do my requires/includes does not have an affect (i.e. no "working" is ever printed out). Hope someone has a solution. Thanks!
Of all the various Ruby library's, the clumsiest to work with and ugliest, in my opinion, would have to be net::http. Have you considered switching to something like this:
https://github.com/dbalatero/typhoeus
The requests in typhoeus occur via lib-curl and so aren't bound by Ruby's not-so-reliable when nested or threaded timeout method.
In terms of the rbuf_fill issue, I'm not sure if that will get you there. If I remember correctly, when a timeout exception fires, it always shows the location that the code is currently at in the stack. That location is only incidental. Take the example below I just ran in irb. Notice how it tells you the timeout occured in "sleep"? Where the timeout is reported is just what it happened to be doing at that moment, not where the timeout code is necessarily implemented, nor do you know which timeout it is that is tripping if there are multiple. I'd have to chase down the rbuf_fill to confirm this for you though, and I have to run at the moment...
irb> timeout(2){sleep 5}
Timeout::Error: execution expired
from (irb):3:in sleep'
from (irb):3:inblock in irb_binding'
from (irb):3
from /home/ebelan

Resources