PDA

View Full Version : Ruby and network communication


jeremy
October 14th, 2005, 06:32 PM
I am having this very frustrating problem with a Win XP machine. Whenever ruby tries to make any network communication (to localhost or otherwize), it just hangs. It hangs when gem tries to load anything from rubyforge, hangs when trying connect to MySQL when running generate scripts, and WEBrick hangs whenever I try to browse to it. And it isn't timing out either, it hangs to the point that I have to manually end the process. For example, I can start WEBrick, and then close it with just ctrl-C, but if I open it and then hit it with a browser, the process hangs and I have to manually end it.

I have tried disabling the Windows firewall, enabling and allowing ruby through, allowing port 3000 through (although really this shouldn't be necessary). Communication to IIS works, I have eclipse that can connect to its update sites, and I can use the MySQL Query Browser with no problems. It seems to be completely isolated to anything ruby. I also have another XP machine that is pretty much configured the same (with firewall enabled), and it works with all of these fine. I am not sure if the other (working) maching has the latest ruby, but I am pretty sure it does.

I really have no idea where to begin figuring out what is going on, does anyone have some suggestions?

bluetechnx
October 14th, 2005, 09:07 PM
Well, in the world of windows I can't really say check the log files (you might be able to find one for the improperly shutdown process?? maybe??). I think it may not be something you want to hear, but I would suggest reinstalling Ruby.

I haven't heard of this problem before, nor have I encountered it.

my 2 cents.

rob
October 17th, 2005, 12:34 AM
This is an interesting problem.

Can you connect to IP's and not hostnames, or neither? Can you make a small ruby script to try to pull down a page via IP?

This will rule out ruby having any problems with name resolution.

jeremy
October 18th, 2005, 03:04 PM
Thanks for the replies...

I have tried reinstalling, but still have the same issues. So I tested this example code from the online Programming Ruby book:

require 'net/http'

h = Net::HTTP.new('www.pragmaticprogrammer.com', 80)
resp, data = h.get('/index.html', nil)
if resp.message == "OK"
data.scan(/<img src="(.*?)"/) { |x| puts x }
end

...and it hangs. I created the equivalent code in Java and it worked (albiet with about 4 times as much code :) ). This is quite frustrating.

Edit: Oh, and I did try changing 'www.pragmaticprogrammer.com' to '161.58.146.238' which is their IP address.

Edit 2: If I run TCP Spy I can see that a connection is established and ready to receive data, but no data ends up getting sent.

rob
October 19th, 2005, 10:12 PM
Some more things to check (some are just shots in the dark):

Try a different site? A different port (say 110 or something)?
Try localhost and port 3000.. see if you can get content from that Rob