无法从IPv6连接到IPv4错误域= NSURLErrorDomain代码=

编程入门 行业动态 更新时间:2024-10-19 09:34:01
本文介绍了无法从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代码=

本文发布于:2023-11-26 18:16:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1634653.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:连接到   错误   代码   NSURLErrorDomain

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!