dns: Windows Error: DNS query for google.com failed: too many retries

The code used is (using v0.4.3):

<?php
// dns.php
error_reporting(PHP_INT_MAX);

require_once 'vendor/autoload.php';

$loop = \React\EventLoop\Factory::create();
$factory = new \React\Dns\Resolver\Factory();
$dns = $factory->create('8.8.8.8', $loop);

$dns->resolve($argv[1])
    ->then(
        function ($ip) { echo "Host: $ip\n"; },
        function ($e) { echo "Error: {$e->getMessage()}\n"; }
);

$loop->run();

The command:

php dns.php google.com

The error:

Error: DNS query for google.com failed: too many retries

Is there any way I can debug this further to find out what’s causing this? The same code on my linux box works just fine…

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 28 (10 by maintainers)

Most upvoted comments

This appears to be a problem with how PHP handles UDP streams when stream_get_contents is called with a maxlength set, specifically on windows systems. I submitted a php bug report about this here: https://bugs.php.net/bug.php?id=74090

A fix is to change public $bufferSize = 65536 to $bufferSize = null in react/stream/src/Stream.php

Windows 10 users of a library I develop are also experiencing this problem, I haven’t been able to test as I don’t have a Windows 10 machine.