ruby - Rails HTTP Ping to unreliable Target -


i send http request ip address , port determine if there device online can respond @ address.

i want have relatively reasonable timeout application not hang while connecting, if there's no. have been using net::http, there not seem way set timeout when using ip address.

res = net::http.get_response(ip_address, '/index.html', port) 

is there best practice or better method perform request or way set timeout in net::http when using ip address rather domain name?

i'm using ruby 2.1.5 , rails 4.1.0 hosting on heroku.

there's no major difference between requesting via ip address or dns name, in latter case dns query made , host-header set, after request done via ip.

in net::http there's open_timeout setting raises net::opentimeout when set if connection cannot established during period. default it's nil means 'forever'


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -