Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
internalsystemerror opened this issue Jan 23, 2017 · 28 comments
Closed

Comments

@internalsystemerror
Copy link

internalsystemerror commented Jan 23, 2017

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

@clue
Copy link
Member

clue commented Jan 23, 2017

Thanks for reporting!

What Windows version are you using?
Does the test suite yield any errors?

Perhaps you can try patching the Executor class and raise the timeout value and/or patch the RetryExecutor and patch the number of retries?

@WyriHaximus
Copy link
Member

Seeing the same error on my windows 10 gaming desktop. One test fails:

There was 1 failure:

1) React\Tests\Dns\FunctionalTest::testResolveGoogleResolves
Expectation failed for method name is equal to <string:__invoke> when invoked 1 time(s).
Method was expected to be called 1 times, actually called 0 times.

I'll make a PR with AppVeyor configuration, @clue or @cboden could you setup AppVeyor for this repository?

@internalsystemerror
Copy link
Author

internalsystemerror commented Jan 23, 2017

Windows 10 + updates (not sure the exact build anymore, it changes without me knowing these days) ... I'll run the test suites when I get back... I'm sure it's probably related to php configuration on windows... One thing I did try already was increasing the timeout and retries, with same result

@internalsystemerror
Copy link
Author

Confirming that running the testsuite on windows gives the error quoted by @WyriHaximus.

@davidcole1340
Copy link

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.

@kassmed
Copy link

kassmed commented Feb 3, 2017

I have the same issue on windows server 2008 R2, but that is w7 basically, not w10. Any solution?

@MrPh1l
Copy link

MrPh1l commented Feb 7, 2017

Anyone found a temporary way of bypassing this bug?

@WyriHaximus
Copy link
Member

Anyone found a temporary way of bypassing this bug?

Will try and look into it tonight when I don't forget. Something you could try in the mean time is using your local DNS server (most likely your router) instead of the Google's DNS server (8.8.8.8 and 8.8.4.4) or try a different open DNS service like OpenDNS (208.67.222.222 and 208.67.220.220)

@kassmed
Copy link

kassmed commented Feb 7, 2017

@WyriHaximus Already tried workarounds like that. Doesn't help. It seems to be a problem only on windows though. Setting in system DNS servers, hardcoding DNS servers or even manually inserting the resolved IP in the hosts file does not help the problem.

@WyriHaximus
Copy link
Member

@kassmed Bonkers does UDP work at all on windows? You could use https://github.com/reactphp/datagram/tree/master/examples to test that

@kassmed
Copy link

kassmed commented Feb 7, 2017

@WyriHaximus Seems to work fine on localhost, but externally i get the same error. Here is a picture of both runs:
https://gyazo.com/67987ed351262a4aaf505130f38a8e76

@WyriHaximus
Copy link
Member

@kassmed don't let datagram do the DNS look up, provide it an IP instead of a hostname to work around that

@kassmed
Copy link

kassmed commented Feb 7, 2017

@WyriHaximus Well now i can make my websocket connect, but now i just have the problem that the CN does not match the certificate when using wss, so the connection handshake fails.

@kassmed
Copy link

kassmed commented Feb 7, 2017

@WyriHaximus I managed to make a REALLY dodgy bypass. In react\socket-client\src\SecureConnector.php i found the line:
'peer_name' => $host

Here i just hardcoded the hostname of what i wanted to connect to, but let the socket connect to the IP directly without DNS lookup.

@kassmed
Copy link

kassmed commented Feb 7, 2017

@WyriHaximus Well, that fix turned out to not work 100% for me, but it might help someone else.

@WyriHaximus
Copy link
Member

@kassmed on my way home now, will look at it after dinner 😄

@WyriHaximus
Copy link
Member

@kassmed haven't had any success yet, will keep trying the rest of the week. Can reproduce the results in native git and the ubuntu sub system on windows. But it's working fine from within a vagrant box on the same machine.

@Jimmy062006
Copy link

No idea if this helps at all.

http://pastebin.com/ZKFaPauu

@Jimmy062006
Copy link

Does the request look like its formatted correctly in my pastebin ?

@micksam7
Copy link

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

@clue
Copy link
Member

clue commented Feb 13, 2017

Thanks for digging into this @micksam7! 👍

Does anybody feel like filing a PR to fix this for this component in the meantime? :shipit:

Also, this should ultimately be fixed via #12 instead.

@Jimmy062006
Copy link

Jimmy062006 commented Feb 13, 2017

Testing buffersize fix on a windows machine now.

EDIT:

This works fine, I'll try and get a PR done when I'm awake for you if its not happened all ready.

@Jimmy062006
Copy link

PR made reactphp/stream#65

@internalsystemerror
Copy link
Author

@micksam7 Thank you! Been struggling to figure that out, I guess I just assume PHP works flawlessly :/
@Jimmy062006 Thanks for the fix also!

@TheMeq
Copy link

TheMeq commented Mar 2, 2017

Note: Issue also affects Windows Server 2012 R2.

@clue
Copy link
Member

clue commented Mar 9, 2017

Closed via #53

@ScorpioKC
Copy link

I'm having the very same problem on my phone.Operating system is Android 7.0

@clue
Copy link
Member

clue commented Feb 20, 2018

@ScorpioKC We're not aware of any issues currently. Can you give some instructions on how to reproduce the problem you're seeing? Also, output of php -v and composer info would help 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants