NSURLErrorDomain代码

NSURLErrorDomain代码

本文介绍了无法从IPv6连接到IPv4错误域= NSURLErrorDomain代码= -1003“找不到具有指定主机名的服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从我的iOS应用程序(设备)调用API到服务器时出现以下错误。

I got the below error, while calling API from my iOS app (device) to server.

我的设备已连接到IPv6网络&我打电话的API是IPv4网络。我使用swift创建了应用程序,我使用Alamofire调用API和Reachability来检查Internet连接。我该怎么办呢。请建议以下错误。

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}}}


推荐答案

您的应用程序需要检查DNS中的A和AAAA记录。即使服务器只有A记录。如果您使用的是仅支持IPv6的网络,则本地DNS解析程序将模拟AAAA记录,您似乎可以从应用程序与IPv6服务器对话。网络将在幕后处理IPv6到IPv4的转换。

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.

这篇关于无法从IPv6连接到IPv4错误域= NSURLErrorDomain代码= -1003“找不到具有指定主机名的服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 19:02