间歇'远程名称无法解决'?

时间:2021-02-24 01:58:05

I have an ASP.NET application that I use to read the contents of a web page by a HttpWebRequest frequently. There's no problem with the remote address and my application is always working fine.

我有一个ASP.NET应用程序,我用它经常通过HttpWebRequest读取网页的内容。远程地址没有问题,我的应用程序始终正常工作。

While I don't change anything, sometimes (about once a day) I get this error:

虽然我没有改变任何东西,有时(大约每天一次)我得到这个错误:

the remote name could not be resolved.

Why a previously resolved DNS name sometimes fails to be resolved?

为什么之前解析的DNS名称有时无法解析?

2 个解决方案

#1


9  

The intermittent nature of this is going to be extremely difficult to resolve and it's going to take a configuration change instead of a code solution. (hint: read everything ;)

这种间歇性的解决方案将非常难以解决,而且需要进行配置更改而不是代码解决方案。 (提示:阅读所有内容;)

I would guess that the remote servers DNS is set to expire pretty often. Probably daily or maybe even every 12 hours or so. This is the TTL (time to live) setting. Admins sometimes set this to an artificially low level if they need the ability to quickly move the site to a new server.

我猜想远程服务器DNS设置为经常过期。可能每天或甚至每12个小时左右。这是TTL(生存时间)设置。如果管理员需要能够快速将站点移动到新服务器,则有时会将其设置为人为的低级别。

You can determine how often it expires by going to a command prompt and running:

您可以通过转到命令提示符并运行来确定它到期的频率:

nslookup
set debug
www.theserverdomain.com

At the top of this will be a section that says "AUTHORITY RECORDS:" with an item under it that says "ttl".

最重要的是一个部分,上面写着“AUTHORITY RECORDS:”,其下面的项目是“ttl”。

Now, (and I'm making an educated guess here), what's probably happening when you query your DNS server to resolve that host name your server will have this value cached.

现在,(我在这里做了一个有根据的猜测),当您查询DNS服务器以解析该服务器将缓存此值的主机名时,可能会发生什么。

However, once it expires the your server will have to contact another server upstream to get the ip address resolution, called DNS forwarding. If there are a lot of hops between yours and the remote server OR if one of the DNS servers between the sites is overloaded then it could timeout and send back the message you are receiving.

但是,一旦它到期,您的服务器将不得不联系上游的另一台服务器以获取IP地址解析,称为DNS转发。如果您和远程服务器之间有很多跳,或者如果站点之间的DNS服务器之一过载,则它可能会超时并发回您收到的消息。

If this is true then the ONLY thing you can do is hardcode the DNS and IP address combination in your web servers hosts file. This is usually at C:\Windows\System32\drivers\etc and is a file named "hosts". There is an example on how to properly edit this within the file itself.

如果这是真的,那么您唯一可以做的就是对Web服务器主机文件中的DNS和IP地址组合进行硬编码。这通常位于C:\ Windows \ System32 \ drivers \ etc,并且是名为“hosts”的文件。有一个例子说明如何在文件本身中正确编辑它。

Once you create the host mapping in that file, your web server will no longer have to contact the DNS server to perform name resolution and it won't matter what the TTL is set to.

在该文件中创建主机映射后,您的Web服务器将不再需要与DNS服务器联系以执行名称解析,并且将TTL设置为什么并不重要。

The only danger here is if they move the web site to a new IP address. At which point you could simply update your hosts file again...

这里唯一的危险是他们将网站移动到新的IP地址。此时您可以再次更新您的主机文件...

#2


1  

The first thing I would check is if DNS is no longer correctly configured or malfunctioning.

我要检查的第一件事是DNS是否不再正确配置或出现故障。

Try (from a Windows command line)

尝试(从Windows命令行)

nslookup MyDnsNameHere

and see if you get the IP you would expect.

看看你是否得到了你所期望的IP。

#1


9  

The intermittent nature of this is going to be extremely difficult to resolve and it's going to take a configuration change instead of a code solution. (hint: read everything ;)

这种间歇性的解决方案将非常难以解决,而且需要进行配置更改而不是代码解决方案。 (提示:阅读所有内容;)

I would guess that the remote servers DNS is set to expire pretty often. Probably daily or maybe even every 12 hours or so. This is the TTL (time to live) setting. Admins sometimes set this to an artificially low level if they need the ability to quickly move the site to a new server.

我猜想远程服务器DNS设置为经常过期。可能每天或甚至每12个小时左右。这是TTL(生存时间)设置。如果管理员需要能够快速将站点移动到新服务器,则有时会将其设置为人为的低级别。

You can determine how often it expires by going to a command prompt and running:

您可以通过转到命令提示符并运行来确定它到期的频率:

nslookup
set debug
www.theserverdomain.com

At the top of this will be a section that says "AUTHORITY RECORDS:" with an item under it that says "ttl".

最重要的是一个部分,上面写着“AUTHORITY RECORDS:”,其下面的项目是“ttl”。

Now, (and I'm making an educated guess here), what's probably happening when you query your DNS server to resolve that host name your server will have this value cached.

现在,(我在这里做了一个有根据的猜测),当您查询DNS服务器以解析该服务器将缓存此值的主机名时,可能会发生什么。

However, once it expires the your server will have to contact another server upstream to get the ip address resolution, called DNS forwarding. If there are a lot of hops between yours and the remote server OR if one of the DNS servers between the sites is overloaded then it could timeout and send back the message you are receiving.

但是,一旦它到期,您的服务器将不得不联系上游的另一台服务器以获取IP地址解析,称为DNS转发。如果您和远程服务器之间有很多跳,或者如果站点之间的DNS服务器之一过载,则它可能会超时并发回您收到的消息。

If this is true then the ONLY thing you can do is hardcode the DNS and IP address combination in your web servers hosts file. This is usually at C:\Windows\System32\drivers\etc and is a file named "hosts". There is an example on how to properly edit this within the file itself.

如果这是真的,那么您唯一可以做的就是对Web服务器主机文件中的DNS和IP地址组合进行硬编码。这通常位于C:\ Windows \ System32 \ drivers \ etc,并且是名为“hosts”的文件。有一个例子说明如何在文件本身中正确编辑它。

Once you create the host mapping in that file, your web server will no longer have to contact the DNS server to perform name resolution and it won't matter what the TTL is set to.

在该文件中创建主机映射后,您的Web服务器将不再需要与DNS服务器联系以执行名称解析,并且将TTL设置为什么并不重要。

The only danger here is if they move the web site to a new IP address. At which point you could simply update your hosts file again...

这里唯一的危险是他们将网站移动到新的IP地址。此时您可以再次更新您的主机文件...

#2


1  

The first thing I would check is if DNS is no longer correctly configured or malfunctioning.

我要检查的第一件事是DNS是否不再正确配置或出现故障。

Try (from a Windows command line)

尝试(从Windows命令行)

nslookup MyDnsNameHere

and see if you get the IP you would expect.

看看你是否得到了你所期望的IP。