tags:

views:

29

answers:

1

Hi, list

Now I am coding for one non-blocking httpclient based on event-machine, and it seems the client will hang for 50 seconds if the destination is unreachable. My questions are

  1. How can I short the timeout? I had tried conn.set_comm_inactivity_timeout(5), but it didn't work
  2. How can I add TimeoutHandler to the connection?

Thanks!

/Jack

A: 

I don't know if it'S 100% what you are looking for, but ruby has a timeout class in its standard lib (--> http://www.ruby-doc.org/stdlib/libdoc/timeout/rdoc/index.html )

  require 'timeout'
  status = Timeout::timeout(5) {
    # Something that should be interrupted if it takes too much time...
  }
Marc Seeger