Net::Ping::HTTP inconsistencies

I have multiple websites that are "up". That is, they are accessible via
the browser and return to the user content.

But...

require 'net/ping'

=> true

Net::Ping::HTTP.new('somewebsite.com').ping?

=> false

And, sometimes (I stress, _sometimes_):

require 'net/ping'

=> true

Net::Ping::HTTP.new('http://somewebsite.com').ping?

=> true

But then...

require 'net/ping'

=> true

Net::Ping::HTTP.new('http://somewebsite.com').ping?

=> false

Why the inconsistency? More importantly, how can I achieve consistent
results? It's maddening when a website is obviously functional and yet I
am told it's not.

···

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

system(%{echo "HEAD / HTTP/1.1\nHOST: www.rabbitcreative.com\n\n" | nc
http://www.rabbitcreative.com 80})

Really? Ruby's Net/* libraries suck, apparently.

···

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

Try this and see if you can determine why it's failing sometimes:

require 'net/ping'

http = Net::Ping::HTTP.new('http://somewebsite.com')

unless http.ping?
  puts "Ping failed: " + ping.exception
end

Regards,

Dan

···

On Apr 19, 3:33 pm, Daniel Waite <rabbitb...@gmail.com> wrote:

I have multiple websites that are "up". That is, they are accessible via
the browser and return to the user content.

But...

>> require 'net/ping'
=> true
>> Net::Ping::HTTP.new('somewebsite.com').ping?

=> false

And, sometimes (I stress, _sometimes_):

>> require 'net/ping'
=> true
>> Net::Ping::HTTP.new('http://somewebsite.com').ping?

=> true

But then...

>> require 'net/ping'
=> true
>> Net::Ping::HTTP.new('http://somewebsite.com').ping?

=> false

Why the inconsistency? More importantly, how can I achieve consistent
results? It's maddening when a website is obviously functional and yet I
am told it's not.

On what basis do you come to this conclusion? Maybe your webserver is not accepting all connection attempts to control the load. Maybe there are network issues. So far I have not seen evidence that there is something wrong with Ruby's net library. (Btw, which version are you using?)

Cheers

  robert

···

On 04/19/2010 11:57 PM, Daniel Waite wrote:

system(%{echo "HEAD / HTTP/1.1\nHOST: www.rabbitcreative.com\n\n" | nc http://www.rabbitcreative.com 80})

Really? Ruby's Net/* libraries suck, apparently.

--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

net-ping isn't part of the Ruby standard library. There's a ping
library, but net-ping is a different beast.

Also, your problem did inspire me to make one change, which is to
alter the Net::Ping::HTTP class so that a URI without a path assumes
'/' for the path.

Regards,

Dan

···

On Apr 19, 3:57 pm, Daniel Waite <rabbitb...@gmail.com> wrote:

system(%{echo "HEAD / HTTP/1.1\nHOST:www.rabbitcreative.com\n\n" | nchttp://www.rabbitcreative.com80})

Really? Ruby's Net/* libraries suck, apparently.