amphp / dns

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

DNS frequently fails on Windows #95

Closed Bilge closed 1 year ago

Bilge commented 4 years ago

A little over 50% of the time, a async CLI application fails to start on Windows because the DNS doesn't work. Once it works, the problem does not seem to occur again, but there's a high probability it will fail unrecoverably at each process start. The operation is retried 5 times and the same error continues to occur until a new PHP process is started, when the dice is re-rolled to see if DNS is actually going to work. It doesn't matter if a process successfully ran a few seconds ago, all rolls are independent and have an equal chance of failing, despite recent successful resolutions by another process.

In BasicResolver.php line 149:

[Amp\Dns\DnsException] All query attempts failed for example.com: Reading from the server failed, Reading from the server failed

amphp/dns v0.9.15

Bilge commented 4 years ago

@kelunik This is still an issue on Windows/PHP 7.4. Happens frequently with Xdebug enabled (about 50% of the time).

In BasicResolver.php line 149:

  [Amp\Dns\DnsException]
  All query attempts failed for store.steampowered.com: Unexpected error during resolution: Trying to read from a previously fclose()'d resource. Do NOT manually fclose() resources the loop still has a reference to., Unexpected error
  during resolution: Trying to read from a previously fclose()'d resource. Do NOT manually fclose() resources the loop still has a reference to.

Exception trace:
  at vendor\amphp\dns\lib\BasicResolver.php:149
 Amp\Dns\BasicResolver->Amp\Dns\{closure}() at n/a:n/a
 Generator->throw() at vendor\amphp\amp\lib\Coroutine.php:115
 Amp\Coroutine->Amp\{closure}() at vendor\amphp\amp\lib\Failure.php:33
 Amp\Failure->onResolve() at vendor\amphp\amp\lib\Internal\Placeholder.php:40
 class@anonymous\vendor\amphp\amp\lib\Deferred.php:22$25d->onResolve() at vendor\amphp\amp\lib\Internal\PrivatePromise.php:23
 Amp\Internal\PrivatePromise->onResolve() at vendor\amphp\amp\lib\Coroutine.php:151
 Amp\Coroutine->__construct() at vendor\amphp\amp\lib\functions.php:86
 Amp\call() at vendor\amphp\dns\lib\BasicResolver.php:167
 Amp\Dns\BasicResolver->resolve() at vendor\amphp\dns\lib\functions.php:49
 Amp\Dns\resolve() at vendor\amphp\socket\src\functions.php:90
 Amp\Socket\{closure}() at n/a:n/a
 Generator->current() at vendor\amphp\amp\lib\Coroutine.php:67
 Amp\Coroutine->__construct() at vendor\amphp\amp\lib\functions.php:86
 Amp\call() at vendor\amphp\socket\src\functions.php:179
 Amp\Socket\connect() at vendor\amphp\socket\src\BasicSocketPool.php:80
 Amp\Socket\BasicSocketPool->Amp\Socket\{closure}() at n/a:n/a
 Generator->current() at vendor\amphp\amp\lib\Coroutine.php:67
 Amp\Coroutine->__construct() at vendor\amphp\amp\lib\functions.php:86
 Amp\call() at vendor\amphp\socket\src\BasicSocketPool.php:111
 Amp\Socket\BasicSocketPool->checkoutNewSocket() at vendor\amphp\socket\src\BasicSocketPool.php:51
 Amp\Socket\BasicSocketPool->checkout() at vendor\amphp\http-client\lib\HttpSocketPool.php:78
 Amp\Artax\HttpSocketPool->checkout() at vendor\amphp\http-client\lib\DefaultClient.php:419
 Amp\Artax\DefaultClient->doWrite() at vendor\amphp\http-client\lib\DefaultClient.php:201
 Amp\Artax\DefaultClient->Amp\Artax\{closure}() at n/a:n/a
 Generator->current() at vendor\amphp\amp\lib\Coroutine.php:67
 Amp\Coroutine->__construct() at vendor\amphp\amp\lib\functions.php:86
 Amp\call() at vendor\amphp\amp\lib\functions.php:122
 Amp\asyncCall() at vendor\amphp\http-client\lib\DefaultClient.php:205
 Amp\Artax\DefaultClient->doRequest() at vendor\amphp\http-client\lib\DefaultClient.php:115
 Amp\Artax\DefaultClient->Amp\Artax\{closure}() at n/a:n/a
 Generator->send() at vendor\amphp\amp\lib\Coroutine.php:118
 Amp\Coroutine->Amp\{closure}() at vendor\amphp\amp\lib\Success.php:41
 Amp\Success->onResolve() at vendor\amphp\amp\lib\Coroutine.php:151
 Amp\Coroutine->__construct() at vendor\amphp\amp\lib\functions.php:86
 Amp\call() at vendor\amphp\http-client\lib\DefaultClient.php:171
 Amp\Artax\DefaultClient->request() at vendor\connectors\http\src\AsyncHttpConnector.php:51
 ScriptFUSION\Porter\Net\Http\AsyncHttpConnector->ScriptFUSION\Porter\Net\Http\{closure}() at n/a:n/a
 Generator->current() at vendor\amphp\amp\lib\Coroutine.php:67
 Amp\Coroutine->__construct() at vendor\amphp\amp\lib\functions.php:86
 Amp\call() at vendor\connectors\http\src\AsyncHttpConnector.php:71
 ScriptFUSION\Porter\Net\Http\AsyncHttpConnector->fetchAsync() at vendor\scriptfusion\porter\src\Connector\ImportConnector.php:110
 ScriptFUSION\Porter\Connector\ImportConnector->ScriptFUSION\Porter\Connector\{closure}() at n/a:n/a
 Generator->send() at vendor\amphp\amp\lib\Coroutine.php:118
 Amp\Coroutine->Amp\{closure}() at vendor\amphp\amp\lib\Success.php:41
 Amp\Success->onResolve() at vendor\amphp\amp\lib\Coroutine.php:151
 Amp\Coroutine->__construct() at vendor\amphp\amp\lib\functions.php:86
 Amp\call() at vendor\scriptfusion\porter\src\Connector\ImportConnector.php:113
 ScriptFUSION\Porter\Connector\ImportConnector->ScriptFUSION\Porter\Connector\{closure}() at vendor\scriptfusion\retry\src\retry.php:34
 ScriptFUSION\Retry\{closure}() at n/a:n/a
 Generator->send() at vendor\amphp\amp\lib\Coroutine.php:118
 Amp\Coroutine->Amp\{closure}() at vendor\amphp\amp\lib\Internal\Placeholder.php:149
 class@anonymous\vendor\amphp\amp\lib\Deferred.php:22$25d->resolve() at vendor\amphp\amp\lib\Deferred.php:52
 Amp\Deferred->resolve() at vendor\amphp\amp\lib\functions.php:410
 Amp\Promise\{closure}() at vendor\amphp\amp\lib\Internal\Placeholder.php:149
 Amp\Delayed->resolve() at vendor\amphp\amp\lib\Delayed.php:25
 Amp\Delayed->Amp\{closure}() at vendor\amphp\amp\lib\Loop\NativeDriver.php:122
 Amp\Loop\NativeDriver->dispatch() at vendor\amphp\amp\lib\Loop\Driver.php:138
 Amp\Loop\Driver->tick() at vendor\amphp\amp\lib\Loop\Driver.php:72
 Amp\Loop\Driver->run() at vendor\amphp\amp\lib\Loop.php:95
 Amp\Loop::run() at src\Command\ImportAppDetailsCommand.php:59
 ScriptFUSION\Club250\Command\ImportAppDetailsCommand->execute() at vendor\symfony\console\Command\Command.php:255
 Symfony\Component\Console\Command\Command->run() at vendor\symfony\console\Application.php:930
 Symfony\Component\Console\Application->doRunCommand() at vendor\symfony\framework-bundle\Console\Application.php:97
 Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() at vendor\symfony\console\Application.php:264
 Symfony\Component\Console\Application->doRun() at vendor\symfony\framework-bundle\Console\Application.php:83
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at vendor\symfony\console\Application.php:140
 Symfony\Component\Console\Application->run() at bin\console:38
kelunik commented 4 years ago

@Bilge Seems like you're still using the old version. Could you try with >= 1.0?

Bilge commented 4 years ago

I'm still locked on amphp/dns ^0.9 because I still use amphp/http-client v3. Will let you know how I get on when I can break away from that version.