Network access to IPv4 servers from IPv6 only networks.
Gints last edited by
I'm developing a Qt app that needs to connect to some servers (so far, only over HTTP using QNetworkAccessManager + QNetworkRequest) to get/post some data. The server addresses are mainly provided by the users, as the users are also mostly setting up and maintaining the servers themselves. Most of the servers are IPv4 only.
Everything works fine as long as the client devices are connecting to the internet from an IPv4 only / dual stack network.
But when the user device is connected to an IPv6 only network (as, for example, will soon be a hard requirement for AppStore apps: https://developer.apple.com/news/?id=05042016a ), I'm running into some trouble.
As long as the servers have properly set up DNS records, and the user enters the hostname, not the IPv4 address, everything works correctly - the hostname resolves to a Well-Known-Prefix IPv6 address [64:ff9b::xxxx:xxxx] that wraps the IPv4 address and the TCP connections succeed.
But, if the user enters the IPv4 address (either by choice or simply because their server does not have DNS), say 184.108.40.206, things start failing. I end up initiating a QNetworkRequest with a url of something like: "http://220.127.116.11:8080/path" and Qt does not try to wrap that IPv4 address in a WKP IPv6 address (as, I'm sure, is the expected behaviour). Now, if I manually change the IPv4 address to a WKP IPv6 address before I initiate the request to something like "http://[64:ff9b::xxxx:xxxx]:8080/path", everything works fine.
But I can't always do that, since the user might be on an IPv4 only network. I also can't ask the users to decide if they are on an IPv4/IPv6 network and enter the address/change some configuration option to auto change the address accordingly, since the app is not aimed at technically literate people (at least the PM says so). I also can't just try the IPv4 address, and then, if that fails, try IPv6, since the IPv4 attempt can take some time (based on my testing on various Android / iOS devices) and I can't introduce that latency.
Is there there a clean solution to this? Is there a way to detect, preferably through some portable Qt interface, that the app is running on a device that currently only has IPv6 connectivity, and I should not attempt HTTP requests to literal IPv4 addresses, but instead wrap them in IPv6? Is there a plan to build similar functionality into Qt, especially now that Apple is adding the IPv6-only support requirement for the AppStore?
Any suggestions on how to handle this without burdening the user with knowledge about IPv4/IPv6, simply letting them enter their IPv4 address and doing what it takes to establish those connections without introducing extra latency?
I'd recommend bringing that question to the interest mailing list. You'll find there Qt's developers/maintainers. This forum is more user oriented.
Gints last edited by
Thank you, I will do that.