Skip to content

DNS query for www.google.com failed: too many retries #78

Closed

Description

@Buheda

Exception unreal4u\TelegramAPI\Exceptions\ClientException caught, message: DNS query for api.telegram.org failed: too many retries

I tried to use only dns too
"name": "react/dns",
"version": "v0.4.11",

from examples
but there is a fail:
DNS query for www.google.com failed: too many retries

01-one.php.txt

Google and api.telegram are enabled and visible from my network and from server network

Activity

  1. clue commented on Sep 9, 2017

    @clue
    Member

    Thanks for reporting! Similar issues have been reported before with #63 and #44 and were believed to be fixed with #74 in v0.4.10.

    Can you give us some more details about the platform you're using, such as:

    $ php --version
    $ composer show

    Our last investigation in #74 revealed this:

    […]This is actually a bug in certain PHP versions on Windows only. This was fixed with PHP 7.0.17 and PHP 7.1.3.

    See https://bugs.php.net/bug.php?id=74090 and php/php-src@89a5bd6.

    […]

    For now, you may be able either downgrade to react/stream < 0.7 or react/dns < 0.4.9 to work around this again.

    Can you verify this?

  2. Buheda commented on Sep 9, 2017

    @Buheda
    Author

    @clue, I tried php 7.0.20 and 7.1.6 (I can't change it. These versions on server)

    clue/block-react            v1.2.0 Integrate async React PHP components into your blocking environment
    evenement/evenement         v2.1.0 Événement is a very simple event dispatching library for PHP
    guzzlehttp/psr7             1.4.2  PSR-7 message implementation that also provides common utility methods
    psr/http-message            1.0.1  Common interface for HTTP messages
    psr/log                     1.0.2  Common interface for logging libraries
    react/cache                 v0.4.1 Async caching.
    react/dns                   v0.4.9 Async DNS resolver for ReactPHP
    react/event-loop            v0.4.3 Event loop abstraction layer that libraries can use for evented I/O.
    react/http-client           v0.5.3 Event-driven, streaming HTTP client for ReactPHP
    react/promise               v2.5.1 A lightweight implementation of CommonJS Promises/A for PHP
    react/promise-timer         v1.2.0 Trivial timeout implementation for Promises
    react/socket                v0.8.1 Async, streaming plaintext TCP/IP and secure TLS socket server and client connections for ReactPHP
    react/stream                v0.7.0 Event-driven readable and writable streams for non-blocking I/O in ReactPHP
    unreal4u/telegram-api       v3.0.0 A complete Telegram bot API implementation written in PHP, with support for inline bots!
    yoshi2889/collections       v0.1.6 Simple Collection class allowing storage of specific data.
    yoshi2889/multipart-builder v0.1.1 Stream-independent RFC2388 compliant multipart form data builder.
    

    react/stream = 0.7 or react/dns = 0.4.9 doesn't work
    react/stream = 0.6 or react/dns = 0.4.8 doesn't work

    It seems problem with php

    Yes, i'm using windows, but if i run this script from android it doesn't work too.
    OS on server is linux

  3. WyriHaximus commented on Sep 9, 2017

    @WyriHaximus
    Member

    @Buheda out of curiosity have you tried one of the examples and see if that works?

  4. Buheda commented on Sep 9, 2017

    @Buheda
    Author

    @WyriHaximus I tried it before downgrade versions and after it. See log in first post. Doesn't work

  5. kelunik commented on Sep 9, 2017

    @kelunik

    @Buheda Just to make sure that we don't have to fix something, too. Could you try the example in https://github.com/amphp/dns and report whether that errors out, too?

  6. Buheda commented on Sep 9, 2017

    @Buheda
    Author

    @kelunik eh.. a have an errors

    Fatal error: Uncaught Amp\Uri\InvalidDnsNameException: Name '' is not a valid hostname. in /home/host1309088/grayshield.ru/htdocs/www/services/telegram/vendor/amphp/uri/src/functions.php:49 Stack trace: #0 /home/host1309088/grayshield.ru/htdocs/www/services/telegram/vendor/amphp/dns/lib/BasicResolver.php(110): Amp\Uri\normalizeDnsName(NULL) #1 [internal function]: Amp\Dns\BasicResolver->Amp\Dns\{closure}() #2 /home/host1309088/grayshield.ru/htdocs/www/services/telegram/vendor/amphp/amp/lib/Coroutine.php(53): Generator->send(NULL) #3 /home/host1309088/grayshield.ru/htdocs/www/services/telegram/vendor/amphp/amp/lib/Internal/Placeholder.php(41): Amp\Coroutine->Amp\{closure}(NULL, NULL) #4 /home/host1309088/grayshield.ru/htdocs/www/services/telegram/vendor/amphp/amp/lib/Coroutine.php(93): Amp\Coroutine->onResolve(Object(Closure)) #5 /home/host1309088/grayshield.ru/htdocs/www/services/telegram/vendor/amphp/amp/lib/functions.php(61): Amp\Coroutine->__construct(Object(Generator)) #6 /home/host1309088/grayshield.ru/htdocs/www/ser in /home/host1309088/grayshield.ru/htdocs/www/services/telegram/vendor/amphp/uri/src/functions.php on line 49
    
  7. clue commented on Sep 10, 2017

    @clue
    Member

    Thanks for reporting back, unfortunately we'll still have to investigate this further:

    Here's what the "DNS query for www.google.com failed: too many retries" error basically means: This component sends a UDP message (DNS query) to your DNS server and waits for a reply. If no answer is received within 5s, it will send a new UDP message and then another one again if no answer is received. If an answer is received, it will verify the response message and resolve the promise. The error shows that no answer has been received.

    So this basically means that we did not receive a reply messageg from your DNS server. This could be due to a number of reasons and could very likely be not something this package has control over.

    Can you update react/dns to the latest version again and check which DNS server you're using and whether a firewall or intermediary proxy could possibly block access to this server? You may also be able to play around with the timeout values in TimeoutExecutor or the number of retries in RetryExecutor. Which DNS server are you using? Can you verify this is correctly listed in the examples you're executing (it is currently hard-coded to Google's 8.8.8.8 there)? Does this error happen all the time? Can you try running the same example on another machine/network to check whether this is related to the network setup?

    I hope this helps 👍

  8. Buheda commented on Sep 10, 2017

    @Buheda
    Author

    @clue Yes. DNS server is 8.8.8.8 I've tried also 8.8.4.4
    unfortunatly none of changes helped...

    I will try run it from local server on my PC

  9. Buheda commented on Sep 10, 2017

    @Buheda
    Author

    @clue The hoster answered me a few minutes ago that they restricted UDP traffic. May be that is a root of problem?

  10. clue commented on Sep 10, 2017

    @clue
    Member

    @Buheda Yes, that would be the problem here. Can you ask your provider for a DNS server that is reachable from within your network? It's likely that they may provide a custom DNS server in their network that is allowed to forward outgoing DNS requests.

  11. Buheda commented on Sep 10, 2017

    @Buheda
    Author

    @clue hoster gave me ip adress their inner NS Server - but nothing changes if i use it..

  12. WyriHaximus commented on Sep 10, 2017

    @WyriHaximus
    Member

    @Buheda Does a dig @HOSTNSSERVERIPADDRESSHERE +tcp reactphp.org returns anything? And what about dig @HOSTNSSERVERIPADDRESSHERE +notcp reactphp.org?

  13. Buheda commented on Sep 10, 2017

    @Buheda
    Author

    @WyriHaximus

     dig 185.26.122.3 +tcp reactphp.org 
    
    ; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.47.rc1.el6_8.4 <<>> 185.26.122.3 +tcp reactphp.org
    ;; global options: +cmd
    ;; Got answer:
    ;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 52375
    ;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0
    
    ;; QUESTION SECTION:
    ;185.26.122.3.			IN	A
    
    ;; AUTHORITY SECTION:
    .			3567	IN	SOA	a.root-servers.net. nstld.verisign-grs.com. 2017091000 1800 900 604800 86400
    
    ;; Query time: 1 msec
    ;; SERVER: 192.168.0.12#53(192.168.0.12)
    ;; WHEN: Sun Sep 10 15:40:57 2017
    ;; MSG SIZE  rcvd: 105
    
    ;; Got answer:
    ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 24213
    ;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 0
    
    ;; QUESTION SECTION:
    ;reactphp.org.			IN	A
    
    ;; ANSWER SECTION:
    reactphp.org.		234	IN	A	104.18.59.228
    reactphp.org.		234	IN	A	104.18.58.228
    
    ;; Query time: 1 msec
    ;; SERVER: 192.168.0.12#53(192.168.0.12)
    ;; WHEN: Sun Sep 10 15:40:57 2017
    ;; MSG SIZE  rcvd: 62
    
  14. Buheda commented on Sep 10, 2017

    @Buheda
    Author

    @WyriHaximus

    $ dig 185.26.122.3 +notcp reactphp.org 
    
    ; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.47.rc1.el6_8.4 <<>> 185.26.122.3 +notcp reactphp.org
    ;; global options: +cmd
    ;; Got answer:
    ;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 6032
    ;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0
    
    ;; QUESTION SECTION:
    ;185.26.122.3.			IN	A
    
    ;; AUTHORITY SECTION:
    .			3591	IN	SOA	a.root-servers.net. nstld.verisign-grs.com. 2017091000 1800 900 604800 86400
    
    ;; Query time: 0 msec
    ;; SERVER: 192.168.0.12#53(192.168.0.12)
    ;; WHEN: Sun Sep 10 15:42:50 2017
    ;; MSG SIZE  rcvd: 105
    
    ;; Got answer:
    ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 1766
    ;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 0
    
    ;; QUESTION SECTION:
    ;reactphp.org.			IN	A
    
    ;; ANSWER SECTION:
    reactphp.org.		121	IN	A	104.18.59.228
    reactphp.org.		121	IN	A	104.18.58.228
    
    ;; Query time: 0 msec
    ;; SERVER: 192.168.0.12#53(192.168.0.12)
    ;; WHEN: Sun Sep 10 15:42:50 2017
    ;; MSG SIZE  rcvd: 62
    
  15. Buheda commented on Sep 11, 2017

    @Buheda
    Author

    @clue may be i can try insert their ip in other files, not only into example?

    Also i've found that their inner DNS ip is absent in /etc/resolv.conf
    Does it matter?

  16. clue commented on Sep 11, 2017

    @clue
    Member

    @Buheda This is strange, the dig output looks good to me. I'm currently out of ideas and given that your provider seems to be blocking certain types of connections, I would suggest checking back with them (perhaps they allow some custom whitelist etc.).

    Also i've found that their inner DNS ip is absent in /etc/resolv.conf
    Does it matter?

    This project does not currently use this file (see #29), but it's still strange that this isn't listed on your system. This makes me wonder how DNS works on your system in the first place and where your provider blocks your traffic?

    As a temporary work-around you may also be able to simply patch your /etc/hosts file with hard-coded addresses, so that you do no longer rely on DNS in the first place.

    #19 is also slightly related here, as we may be able to send a query over TCP/IP in case UDP connections are blocked.

    In any case, the example uses the same code as the higher-level Connector which is used by higher-level client implementations. See also its documentation: https://github.com/reactphp/socket#connector

    If anybody else has any ideas, please share 👍

  17. Buheda commented on Sep 11, 2017

    @Buheda
    Author

    @clue
    answer from hoster: "there is another ip in resolv.conf that is equal mine
    all requested to external dns are disallowed on virtual hosting"

    So packets go to their inner DNS and after that they have been blocked?

  18. clue commented on Sep 11, 2017

    @clue
    Member

    @Buheda I'm not sure I follow… The /etc/resolv.conf should have one or more nameserver X entries, this value should be used for the call to create() in the examples.

    Note that the Connector is currently hard-coded to default to 8.8.8.8 (see reactphp/socket#90), which your hoster seems to block. This means that you will have to explicitly pass your DNS details to the Connector if you're using a higher-level protocol, such as HTTP etc.

  19. Buheda commented on Sep 11, 2017

    @Buheda
    Author

    @clue all adresses from /etc/resolv.conf gave error
    but hoster's second ip exist in resolv.conf

    But all adresses from hosts give positive answer.

  20. clue commented on Sep 12, 2017

    @clue
    Member

    @Buheda I understand it's frustrating, but at this point there's really little we can do here unfortunately. It looks like your provider is at fault for blocking UDP traffic here. I would suggest telling your provider about this issue and ask to be whitelisted and/or to start looking for another provider.

    Once #19 or #80 is in, you may be able to circumvent your provider blocking certain kinds of traffic, but it appears unsound to rely on this only to circumvent your provider.

    In the meantime, you may be able to patch your hosts file, even pass a custom hosts file and/or use an internal DNS server as documented above.

    I believe this has been answered, so I'm closing this for now. Please come back with more details if this problem persists and we can reopen this 👍

  21. Buheda commented on Sep 12, 2017

    @Buheda
    Author

    @clue thank's for helping me.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions