在android中,自定义url的DNS查找需要花费大量时间(5秒)

在android中,自定义url的DNS查找需要花费大量时间(5秒),android,dns,amazon-route53,Android,Dns,Amazon Route53,我有一个在godaddy注册的域名,但我有53号路由中的DNS服务器 当我试图通过android应用程序ping网站时,DNS解析第一次需要5秒(每10分钟一次)。这不是iOS或mac浏览器的情况,当我试图点击邮递员的url时。这只发生在我的android应用程序中 尝试过的解决方案: 1) 在不同的手机上试过 2) 尝试了不同的网络 所用时间的跟踪: 请求1(新连接) 如果你能在这里帮助我,那将是很大的帮助 编辑:添加代码 String url = "https://customurl/";

我有一个在godaddy注册的域名,但我有53号路由中的DNS服务器

当我试图通过android应用程序ping网站时,DNS解析第一次需要5秒(每10分钟一次)。这不是iOS或mac浏览器的情况,当我试图点击邮递员的url时。这只发生在我的android应用程序中

尝试过的解决方案:

1) 在不同的手机上试过

2) 尝试了不同的网络

所用时间的跟踪: 请求1(新连接)

如果你能在这里帮助我,那将是很大的帮助

编辑:添加代码

String url = "https://customurl/";
OkHttpClient httpClient = new OkHttpClient.Builder()
            .eventListener(new PrintingEventListener())
            .dns(DnsSelector.byName("ipv6"))
            .build();
Retrofit client = new Retrofit.Builder().baseUrl(url).client(httpClient)
            .build();
System.out.println("Scanning REQUEST 1 (new connection) url: " + url);

TestInterface testInterface = client.create(TestInterface.class);

Call<ResponseBody> testCall = testInterface.testCall();
Log.i( TAG, "Scanning apiCall Start");
testCall.enqueue(new Callback<ResponseBody>() {
        @Override
        public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
            Log.i( TAG, "Scanning apiCall end success");
}

        @Override
        public void onFailure(Call<ResponseBody> call, Throwable t) {
            Log.i( TAG, "Scanning apiCall end failed");
        }});
stringurl=”https://customurl/";
OkHttpClient httpClient=新建OkHttpClient.Builder()
.eventListener(新的PrintingEventListener())
.dns(DnsSelector.byName(“ipv6”))
.build();
改装客户端=新建改装.Builder().baseUrl(url).client(httpClient)
.build();
System.out.println(“扫描请求1(新连接)url:”+url);
TestInterface TestInterface=client.create(TestInterface.class);
Call testCall=testInterface.testCall();
Log.i(标记“扫描所有开始”);
enqueue(新的回调(){
@凌驾
公共void onResponse(调用、响应){
Log.i(标记“扫描所有最终成功”);
}
@凌驾
失败时公共无效(调用调用,可丢弃的t){
Log.i(标记“扫描所有端失败”);
}});
在android emulator中速度非常快 0.000呼叫开始

0.010 dnsStart

0.095 dnsEnd

0.096连接启动

0.103安全连接启动

0.537安全连接端

0.563连接端

已获取0.565个连接

0.567请求头开始

0.572请求头端

0.573负责人开始

0.733负责人结束

0.739响应边界

0.740连接已释放


0.740被叫方

我找到了解决办法。我在发布之前尝试过这个解决方案,但由于某种原因,它当时不起作用

如前所述,我添加了一个公共DNS解析程序


这将dns查找时间从5.5秒缩短到300毫秒。虽然从我的角度来看,这仍然很高,但要好得多。

我找到了解决办法。我在发布之前尝试过这个解决方案,但由于某种原因,它当时不起作用

如前所述,我添加了一个公共DNS解析程序

这将dns查找时间从5.5秒缩短到300毫秒。虽然从我的角度来看,这仍然很高,但要好得多。

+1用于询问与编程和开发有关的dns问题。+1用于询问与编程和开发有关的dns问题。
String url = "https://customurl/";
OkHttpClient httpClient = new OkHttpClient.Builder()
            .eventListener(new PrintingEventListener())
            .dns(DnsSelector.byName("ipv6"))
            .build();
Retrofit client = new Retrofit.Builder().baseUrl(url).client(httpClient)
            .build();
System.out.println("Scanning REQUEST 1 (new connection) url: " + url);

TestInterface testInterface = client.create(TestInterface.class);

Call<ResponseBody> testCall = testInterface.testCall();
Log.i( TAG, "Scanning apiCall Start");
testCall.enqueue(new Callback<ResponseBody>() {
        @Override
        public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
            Log.i( TAG, "Scanning apiCall end success");
}

        @Override
        public void onFailure(Call<ResponseBody> call, Throwable t) {
            Log.i( TAG, "Scanning apiCall end failed");
        }});