WebRequest.BeginGetRequestStream fails on iOS using IPv6 DNS64/NAT64

Apple has recently made it a requirement for all apps to support IPv6 DNS64/NAT64 and I’ve been working to comply with this mandate.

I followed Apple’s directions for setting up a DNS64/NAT64 network here (scroll down to Test for IPv6 DNS64/NAT64 Compatibility). Unfortunately when I test our app on that network, I get an exception:

Login Failure received from server, error: Error: NameResolutionFailure
stack Trace:    at System.Net.HttpWebRequest.SetWriteStreamError(WebExceptionStatus status, System.Exception exc)

Based on this it appears that DNS name resolution is failing. I’ve tried this on an IPv4 network, and it worked without error. The only low(-ish) level networking API I’m using is HttpWebRequest.BeginGetRequestStream, and I’m using that because I need to use the HTTP Verb “PUT” to connect with one of our REST services.

I’m hoping there’s simply a configuration I need to set up for HttpWebRequest, as the alternative seems to be writing a lot of custom code to handle DNS64/NAT64 networks. I’ve spent some time with the HttpWebRequest documentation without finding anything that seems to fit. Does anyone have a suggestion or a solution for how I might resolve this issue?

I was finally able to fix this by upgrading from Unity 5.3.2p2 to Unity 5.3.5f1.