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 8024939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:00:02+00:00 2026-06-04T23:00:02+00:00

I have a ruby code that triggers php script over https. Use case: The

  • 0

I have a ruby code that triggers php script over https.

Use case: The php script usually finishes in 5 minutes so I have set up time out for https request after 10 minutes. I need a timer that would trigger code after let’s say 7 minutes after the https request started.

I was thinking of using thread that I created just before I initiate https request. I am not sure if this the correct way to approach this. Maybe there is not need to use threads at all. I am using ruby 1.8.7 (2010-08-16 patchlevel 302) [i386-mingw32]. Also I don’t now if I can ‘kill’ the thread on successful finish of https request.

uri = URI.parse(url)
start = Time.new
http_read_timeout=60*10

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)
            # here I need to place a code that is triggered 
            # in case of custom timeout is reached
        end
rescue Timeout::Error
#  "Connection failed
    time_out_message ="security time out - after #{http_read_timeout} sec"
return time_out_message         

end

puts "finished"
  • 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-04T23:00:05+00:00Added an answer on June 4, 2026 at 11:00 pm

    The basic structure could be like this:

    seconds_timer = MyDelay
    counter = 0
    
    test_thread = Thread.new do
      run_http_php_test
    end
    
    while test_thread.alive?
     counter += 1
     if counter > seconds_timer
       handle_custom_timeout_somehow       
       # if you want to halt run_http_php_test: 
       test_thread.kill if test_thread.alive?
       # otherwise:
       break
     end
     sleep 1
    end
    # the below doesn't apply if you kill the run_http_php_test thread
    test_thread.join if test_thread.alive?
    

    …but of course you could change that sleep 1 to whatever polling interval you like. Polling is nicer than just forcing your original thread to sleep, because the code will finish faster if run_http_php_test is done before you hit your custom timeout value.

    Most or all of your code above can be in the run_http_php_test method, or inserted directly…whichever you’d prefer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an underlying ruby game-engine code and I want to use the web
I have just optimised some Ruby code that was in a controller method, replacing
I have this code that I have written in Ruby, but when trying to
So I have code that runs just fine on ruby 1.8.7, but on 1.9.2
I have seen Ruby code that raises exceptions using a class: raise GoatException, Maximum
I have a struct in my Ruby code that looks somewhat like this Parameter
I have a nice piece of functional and tested Ruby code that I would
Now i have a method in my Ruby script code and basicaly its returning
I have some code that needs to rescue multiple types of exceptions in ruby:
I have a Ruby code that reads file line-by-line and checks if it needs

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.