Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dns_get_record(): A temporary server error occurred.

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

like image 568
Josh Undefined Avatar asked Mar 29 '16 09:03

Josh Undefined


1 Answers

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

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;
}
like image 148
SlovyanskiyYehor Avatar answered Sep 17 '22 17:09

SlovyanskiyYehor