How do I tell LWP to use ipv4 and not ipv6?
Background that might be useful: I have a script that grabs data from our website. Using something like
my $ua = LWP::UserAgent->new; print "Setting Responce" if $debug; print "Why does it hang here for 2min" if $debug; my $response = $ua->request(GET 'https://ourcopanyswebsite.com/xorl/sc +ript147.php'); print "retrieving content\n" if $debug; my $returned_info = $response->content; # do stuff to returned_info and set $useful_data from it print $useful_data;
It works but there's a 120 second delay (and it is always 120 seconds) where the comment asks why does it hang here.
I have noticed if I on the command line do: wget https://ourcopanyswebsite.com/xorl/script147.phpthat there is a similar long delay However if I do wget --inet4-only https://ourcopanyswebsite.com/xorl/script147.php it works fine with no delay.
While I am curious about the delay, some of the useful data I'm trying to get is the IPv4 address of the server running the script and the remote site will send the IPv6 address instead if it goes over that. So I really want to force IPv4 on LWP instead of figuring out the cause of the delay. If relevant, the server it is running on is Ubuntu 22.04.3 LTS.Update: Corion's solution works: Adding before the request $ua->local_address("10.0.0.107") works.
In reply to LWP and ipv4 by xorl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |