Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7951113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:27:49+00:00 2026-06-04T02:27:49+00:00

I have a function that gets response over http. It runs some tests. Lately

  • 0

I have a function that gets response over http. It runs some tests. Lately it started to happen that the test never finishes. So I introduced a time out. Then I found out that if I stop the database server the test script finishes with a db error that is in fact very good lead why the test didn’t finish as expected. So to get the error could help to save me time. Because I wouldn’t have to reproduce the whole test again manually.

Q1: Is there any way to let the connection time out but then get the response after the database server is restarted? Note that I cannot send the http request again as it would start the same text again.

Q2: I think that a solution would be to introduce timer while “waiting” for http response. But I don’t know how to do that. Any idea?

My function is like

def execute_db2_script(url)
  db2_database = 'RATIONAL'
  http_read_timeout=$http_read_timeout
  uri = URI.parse(url)
  start = Time.new

  connection = Net::HTTP.new(uri.host, 443)
  connection.use_ssl = true
  begin 
    response = connection.start() do |http|
      http.open_timeout =  50
      http.read_timeout = http_read_timeout
      http.request_get(uri.request_uri)
    end
  rescue Timeout::Error
    time_out_message ="security time out - after #{$http_read_timeout} sec"
  return time_out_message       
  end       
  return response.body.gsub("\n","<BR>")
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T02:27:50+00:00Added an answer on June 4, 2026 at 2:27 am

    You can use retry keyword

    def execute_db2_script(url)
      ...
      begin 
        ...
      rescue Timeout::Error
        time_out_message ="security time out - after #{$http_read_timeout} sec"
        if "the server is going to restart then"
          retry # this will restart begin-rescue-end block again
        else
          return time_out_message       
        end
      end       
    
      response.body.gsub("\n","<BR>")
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my Java code I have function that gets file from the client in
I have this function in jQuery that gets data from a page with POST,
Okay, so I have an AJAX function that gets a JSON encoded string from
I have a simplified function that looks like this: function(query) { myApi.exec('SomeCommand', function(response) {
I have a HTTP class that gets content from URL's, POST's content to URL's
So I have function that formats a date to coerce to given enum DateType{CURRENT,
I have function Start() that is fired on ready. When I click on .ExampleClick
I have a function that accepts a class (not an instance) and, depending on
I have a function that is being called from different threads in the application.
I have a function that allows users to edit a row in a table

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.