I've got an Alexa Skill hosted in AWS Lambda which uses AsyncHttpClient
to call an IPv6
REST service under the following EXAMPLE URL:
http://[2a12:5375:4151:2300:1353:a632:5f4e:c232]:4711/rest/test
Now my problem is, that I always get the following exception:
ava.util.concurrent.ExecutionException: java.net.ConnectException: Protocol family unavailable
If I check the IP address which is assigned to the underlying server or the application?, I get the following address (also example):
ip-10-23-56-1.eu-west-1.compute.internal: 10.23.56.1
So I think, because I am using an IPv6 while the system uses IPv4, I can't get it working? I can call my REST service from another server successfully.
I am also using the following system properties:
System.setProperty("java.net.preferIPv6Addresses", "true");
System.setProperty("java.net.preferIPv4Stack", "false");
Is there any solution to provide a 'tunnel' over the IPv4 underlying system to tunnel the IPv6 address to call the REST service? Or is there any simpler solution?
Finally, AWS have added IPv6 support to AWS Lambda service but it is not enabled by default; that is the reason you still get those errors.
You need to configure a custom VPC. You can find more details at https://aws.amazon.com/about-aws/whats-new/2023/10/aws-lambda-ipv6-outbound-connections-vpc/