laravel dns_get_record():发生临时服务器错误。

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/36280957/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 13:29:29  来源:igfitidea点击:

dns_get_record(): A temporary server error occurred.

phplaravelexceptiondns

提问by Josh Undefined

I'm querying a whole bunch of addresses, some are online and some are not. I can't seem to get around this error however, even catching the exception fails :(

我正在查询一大堆地址,有些在网上,有些不在。但是,我似乎无法解决此错误,即使捕获异常也失败了:(

 dns_get_record(): A temporary server error occurred. 


        try {
            $result = dns_get_record('_minecraft._tcp.' . $addr, DNS_SRV);
        }
        catch (Exception $e) {
            return [$addr,$port];
        }

If this error occurs, I want to continue the script, skipping the record, however currently the script just halts.

如果发生此错误,我想继续脚本,跳过记录,但目前脚本只是停止。

Any help appreciated!!

任何帮助表示赞赏!

回答by SlovyanskiyYehor

I can't catch this exception too. And how I understood it's a bug of php: https://bugs.php.net/bug.php?id=73149

我也无法捕捉到这个异常。我如何理解它是 php 的错误:https: //bugs.php.net/bug.php?id =73149

But I found another solution. You can use @when you call this function. This symbol kill all errors when you call this one. And it will looks like that:

但我找到了另一个解决方案。@调用此函数时可以使用。当您调用此符号时,此符号会消除所有错误。它看起来像这样:

$dns = @dns_get_record($domain, DNS_A);
if(!$dns){
    return false;
}

回答by e.ventures

try this:

尝试这个:

     try {
         $dns = dns_get_record($domain, DNS_A);
     }
     catch (Exception $e) {
         if ($e->getMessage() !== 'dns_get_record(): A temporary server error     occurred.') {
             throw $e;
         }
         $dns = false;
     }