amphp / dns

Async DNS resolution for PHP based on Amp.
https://amphp.org/dns
MIT License
157 stars 32 forks source link

Incomplete packet error (still exists) #102

Closed NoDiskInDriveA closed 1 year ago

NoDiskInDriveA commented 3 years ago
PHP Warning:  assert(): Trying to read from a previously fclose()'d resource. Do NOT manually fclose() resources the loop still has a reference to. failed in ..../vendor/amphp/byte-stream/lib/ResourceInputStream.php on line 83

Warning: assert(): Trying to read from a previously fclose()'d resource. Do NOT manually fclose() resources the loop still has a reference to. failed in ..../vendor/amphp/byte-stream/lib/ResourceInputStream.php on line 83
PHP Warning:  assert(): Trying to read from a previously fclose()'d resource. Do NOT manually fclose() resources the loop still has a reference to. failed in ..../vendor/amphp/byte-stream/lib/ResourceInputStream.php on line 83

Warning: assert(): Trying to read from a previously fclose()'d resource. Do NOT manually fclose() resources the loop still has a reference to. failed in ..../vendor/amphp/byte-stream/lib/ResourceInputStream.php on line 83

In Rfc1035StubResolver.php line 197:

  All query attempts failed for www.google.com: Unexpected error during resolution: Decode error: Incomplete packet (tri
  ed to read 12 bytes from index 0, Unexpected error during resolution: Decode error: Incomplete packet (tried to read 1
  2 bytes from index 0

In functions.php line 540:

  Multiple errors encountered; use Amp\MultiReasonException::getReasons() to retrieve the array of exceptions thrown

In hope this is helpful: In my setup, I have two DNS server entries of which the first one seems to be misconfigured and never returns any data. LibDNS\Decoder\Decoder raises an UnexpectedValueException in this case, which is converted into a DnsException in Amp\Dns\Internal\Socket::error(). The Rfc1035StubResolver does not catch and handle this by selecting the next nameserver, but fails instead. I've confirmed this with tcpdump as far a my abilities allow.

kelunik commented 1 year ago

https://github.com/amphp/dns/commit/a8c9cee1c3e8b68b59461834eee08460aa8212c4 ignores such invalid packets now and will result in a timeout for that specific server, but also reporting the invalid packet count in the exception message.