Catching Errno::ETIMEDOUT

This is a little method I use to download webpages. It works ok until I
started receiving some Errno::ETIMEDOUT errors that cause my script to fail.

I tried rescuing this error using recue Timeout::Error but it doesn't work.

Any ideas how can I catch this error to avoid the script to fail and just
ignore the error??

def connect
                # Do we have a url to process do we?? if not simply return
                if not @uri
                        return nil
                end

                begin
                        h = Net::HTTP.new(@uri.host, @uri.port)
                        h.use_ssl = true if @uri.scheme == "https"
                        @resp = h.get(@uri.request_uri, nil )

                rescue SocketError
                        @resp = Net::HTTPNotFound.new(1.1, 404, "Not Found")
                end

                return @resp
end

thanks
Horacio

Horacio Sanson wrote:

This is a little method I use to download webpages. It works ok until I
started receiving some Errno::ETIMEDOUT errors that cause my script to
fail.

I tried rescuing this error using recue Timeout::Error but it doesn't
work.

Any ideas how can I catch this error to avoid the script to fail and
just
ignore the error??

def connect
                # Do we have a url to process do we?? if not simply
return
                if not @uri
                        return nil
                end

                begin
                        h = Net::HTTP.new(@uri.host, @uri.port)
                        h.use_ssl = true if @uri.scheme == "https"
                        @resp = h.get(@uri.request_uri, nil )

                rescue SocketError
                        @resp = Net::HTTPNotFound.new(1.1, 404, "Not
Found")
                end

                return @resp
end

Try to rescue SystemCallError (all off the Errno
should fall in this category) or Exception.

thanks
Horacio

E

···

--
Posted via http://www.ruby-forum.com/\.

Hello All,

I am new to Ruby and using selenium automation framework but ended with
following errors.

Can you help me please.

Loaded suite C:/Selenium/RubyWorkingLib/Main
Started
E
Finished in 21.011101 seconds.

  1) Error:
test_new(NewTest):
Errno::ETIMEDOUT: A connection attempt failed because the connected
party did not properly respond after a period of time, or established
connection failed because connected host has failed to respond. -
connect(2)
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/selenium-client-1.2.18/lib/selenium/client/protocol.rb:89:in
`http_post'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/selenium-client-1.2.18/lib/selenium/client/protocol.rb:12:in
`block in remote_control_command'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/selenium-client-1.2.18/lib/selenium/client/protocol.rb:11:in
`remote_control_command'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/selenium-client-1.2.18/lib/selenium/client/protocol.rb:19:in
`string_command'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/selenium-client-1.2.18/lib/selenium/client/base.rb:85:in
`start_new_browser_session'
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/selenium-client-1.2.18/lib/selenium/client/base.rb:99:in
`start'
    C:/Selenium/RubyWorkingLib/Main.rb:29:in `setup'

  2) Error:
test_new(NewTest):
NameError: uninitialized class variable @@excel in NewTest
    C:/Selenium/RubyWorkingLib/Main.rb:38:in `teardown'

1 tests, 1 assertions, 0 failures, 2 errors, 0 skips

Test run options: --seed 60730

···

================================

I have tried with simple google but still getting the same protocol
errors.. it seems like not recognising the protocol utility but I do not
have any idea how to force to use.
Please advise me.

--
Posted via http://www.ruby-forum.com/.