Reputation: 75
How can I tell my Mojolicious Mojo::UserAgent
to use only IPv4, is that possible somehow?
(something like: wget --inet4-only https://blabli.com
)
Reason why I need this is that in Openshift Cluster where I use this Agent, IPv6 doesn't work.
Upvotes: 1
Views: 199
Reputation: 2584
You can force the use of ipv4 using the IO::Socket::IP
module to add socket_options
to the user agents socket.
use Mojo::UserAgent;
use IO::Socket::IP -register;
# PF_INET -> ipv4
# PF_INET6 -> ipv6
my $ua = Mojo::UserAgent->new(socket_options => { Domain => PF_INET });
print $ua->get("www.google.com")->result->body; # Uses ipv4
Upvotes: 8