mconstantine has asked for the wisdom of the Perl Monks concerning the following question:

I'm debugging a problem with a server running on OS X where HTTP requests receive a "500 DNS lookup timeout". There's nothing out of the ordinary with my network setup and my other services (ruby web servers, for instance) are communicating fine with the outside world.

I've traced the problem to this block of code in ParanoidAgent.pm:

# wait for the socket to become readable, unless this is from our test # mock resolver. unless ($sock && $sock eq "MOCK") { my $rin = ''; vec($rin, fileno($sock), 1) = 1; my $nf = select($rin, undef, undef, $self->_time_remain($reque +st)); die "DNS lookup timeout" unless $nf; }

If I comment out the die command, I find that the code never gets a readable socket. I could really use some Perl Wisdom on how to debug this further. What kinds of things can lead to socket problems? Other people running this server on similar hardware report no problems.

Any thoughts?
Much thanks,

Matt

Replies are listed 'Best First'.
Re: Problem with Sockets
by Corion (Patriarch) on Jul 24, 2009 at 14:43 UTC

    I think the first step would be to tell us more about what server you're running. I guess by ParanoidAgent, you mean an instance of a LWP::ParanoidAgent object. So, can you reduce the program you're running to a simple stand-alone test case using only LWP::ParanoidAgent, or are other factors involved? Which request exactly is it that fails? Is it only DNS requests? Can you change the block from using select to synchronously using read or sysread? Is the socket a unix domain socket or a TCP socket? Is it a local connection or a remote connection?

    These are, likely in that order, the questions I'd try to answer. We will try to help you, but we will need a stand-alone test case (less than 60 lines of code) we can run without needing to duplicate much of your setup.

      Thanks, that's exactly the help I needed. I'll reduce the problem to a stand-alone and go from there. Thanks!
Re: Problem with Sockets
by Anonymous Monk on Jul 24, 2009 at 14:42 UTC