-
Notifications
You must be signed in to change notification settings - Fork 11
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
Add a Timeout parameter #42
Comments
That sounds like a useful feature to me. I'll take a look at it 👍 |
Wow @kimbo , cool, that was fast... However, it seems your implementation doesn't work as expected for my use-case : the DoH server is down (ie: service dnsdist stop). You can see here : https://www.frnog.org/test/ |
Well having a timeout is super useful. I would've already done it if I'd have thought of it before.
Not sure if I understand you completely. |
The concept of a timeout as I see it is to fail after TIMEOUT milliseconds, whatever is happening in the background... Here I shut the server in order to simulate a network outage of a DoH server that is not anycast or an outage of a whole AS, like CloudFlare encountered a few months ago... In the UDP world of DNS, if the DNS client doesn't get an answer from the server after a short period (often less than 2 seconds), the client retries with another server. This is documented here (for Windows) : https://support.microsoft.com/en-au/help/2834226/net-dns-dns-client-resolution-timeouts and the same exists on the Linux-side of things : /etc/resolv.conf => options timeout:1 attempts:1 rotate. This is why I talked about FetchWithTimeout in my first post... Here is how I use your library in my code (browser-based HTTP load-balancer), which implements a retry on another DoH server : |
And btw :
If the DoH server is down or is having network issues, the browser will try to connect to it and timeout after 2 seconds (on Chrome)... and in the current implementation of the library, the fetch call is blocking (as opposed to FetchWithTimeout)... thus your current timeout setting is ignored. |
The way I see a timeout is that you fail after TIMEOUT, yes, unless some other fatal error occurs that causes you to fail before the timeout. A timeout isn't a "catch-all" for any error that occurs before the timeout. |
I think the issue is that it isn't failing after The query call should always be done after |
@kimbo But my problem here is that I've set a 500ms timeout on the DoH query... and since Chrome has a TCP timeout of 2s, the query runs for 2s and not 500 ms. The timeout is a maximum allowed, so this should not be occurring... There are no errors occuring before the 500 ms, it's just the browser trying to connect (and I read that on mobile, the wait can be infinite). Btw, even the guys writing the JS standard think there should be a timeout : @jacobgb24 I don't get your last sentence... there's no after/before to me... it's a parallel thing. On one thread you count ms, on another you try to fetch(). After TIMEOUT ms you kill the fetch() thread, if it did not finish before. That's all. Here's a shorter version of the FetchWithTimeout : |
@kimbo : If I try to : I get "undefined"... ! And if I add : So it seems there is an issue with your opts object... So here is the fix : *** 4051,4057 **** |
There is still something a bit ugly though... I've been forced to add "Access-Control-Allow-Headers : *" to my DoH server because your code adds the "requesttimeout" HTTP header to the DoH requests. Is there a reason why you are adding the requesttimeout variable and value as a HTTP header ? |
Adding "headersList.pop();" before "global.fetch(self._opts.url, {" works, but that's not what one could call state of the art... :) |
I would like to be able to specify a timeout in milliseconds for the DoH request.
There are some fetchWithTimeout(URL,Timeout) functions available online that would probably work just fine...
The text was updated successfully, but these errors were encountered: