问题
I got the below error, while calling API from my iOS app (device) to server.
My device is connected to IPv6 network & API which i am calling is with IPv4 network. I created the app using swift and i am using Alamofire for calling API and Reachability for checking Internet connection. What should i do for this. Please suggest on the below error.
Request failed with error: Error Domain=NSURLErrorDomain Code=-1003
"A server with the specified hostname could not be found." UserInfo=
{NSErrorFailingURLStringKey=, _kCFStreamErrorCodeKey=8, NSErrorFailingURLKey=,
NSLocalizedDescription=A server with the specified hostname could not
be found., _kCFStreamErrorDomainKey=12, NSUnderlyingError=0x7a08c530
{Error Domain=kCFErrorDomainCFNetwork Code=-1003 "(null)" UserInfo=
{_kCFStreamErrorDomainKey=12, _kCFStreamErrorCodeKey=8}}}
回答1:
Your application needs to check for both A and AAAA records in DNS. Even if the server only has an A record. If you are on an IPv6-only network the local DNS resolver will simulate the AAAA record and it will seem like you are convection to an IPv6 server from the app. The network will handle the IPv6-to-IPv4 conversion behind the scenes.
来源:https://stackoverflow.com/questions/38604742/unable-to-connect-from-ipv6-to-ipv4-error-domain-nsurlerrordomain-code-1003-a