Comments (17)
Hi, I've been working on this. I've created a PR (#4674) to get some feedback. Thx
from okhttp.
I just ran into this on version 4.11.0, so it appears to still be an issue, but I was able to work around it by wrapping my call with withTimeout
. I'm using coroutines using the technique here: https://github.com/gildor/kotlin-coroutines-okhttp/blob/master/src/main/kotlin/ru/gildor/coroutines/okhttp/CallAwait.kt
As a user, it's surprising to me that the DNS timeout isn't included in the overall callTimeout
.
from okhttp.
Requested upstream: https://code.google.com/p/android/issues/detail?id=56243
from okhttp.
Any news on this? It would be great if we could set a timeout for the DNS lookup. Typical use case is when a user connects to a WiFi that does not have an internet connection. It takes 20-30 seconds until the request fails and there is no way how to reduce this time.
from okhttp.
We are also running into issues with this. Do you know if any progress has been made on a workaround?
from okhttp.
Nothing at the moment. It's a difficult bug to fix because DNS is completely opaque in Java.
from okhttp.
from okhttp.
Maybe we do DNS on a background thread? That’d probably be worth the cost, although potentially surprising.
from okhttp.
One more thing: now that our Dns
interface is public, end-users can do this if they like.
from okhttp.
n.b. This is relevant for dnsoverhttps and there are also other viable dns clients now e.g. Netty impl is straightforward and can support timeouts. It would be nice if this was part of an overall request timeout even for a synchronous call.execute
from okhttp.
I was pondering the right API for this. Is it DnsCall + DnsCallback interfaces? That seems like a lot of code.
Another option is to make the DNS method async with coroutines, but that means we need a Kotlin dependency.
Other ideas?
from okhttp.
Punt until there is a story for a (future?) kotlin based OkHttp, hopefully with native support for coroutines?
In that scenario the system Dns impl, could use a IO thread pool for Dns requests.
from okhttp.
@yschimke @swankjesse Now that there is a kotlin based OkHttp in 4.x.x, is it possible to make more headway on this issue or are there any other blockers?
from okhttp.
Dupe of #5042?
from okhttp.
Yep, these are mutually redundant.
from okhttp.
Yeah, it should be, we just don't have the right API for it. We rely on the system DNS being well behaved. You could also implement your own Dns impl, with some shorter timeout.
from okhttp.
It would probably be more correct to use the AsyncDns implementation
And default to Android Dns which supports it https://github.com/square/okhttp/blob/6b91ea468c6b2931f9092232d8ebcf61076023ff/okhttp-android/src/main/kotlin/okhttp3/android/AndroidAsyncDns.kt
With some other approach for JVM. but not likely soon.
from okhttp.
Related Issues (20)
- callTimeout appears to not be enforced when RequestBody.isDuplex is true HOT 3
- Expose SSE retry time updates via the public API HOT 2
- Not working with AGP 8.2.1 HOT 2
- Flaky HttpOverHttp2Test HOT 3
- All cacheKey override on Request. HOT 19
- Why there is no 4.11.0 release branch? HOT 3
- Crash unable to load publicsuffixes.gz resource from the classpath. HOT 1
- Why wildcard like "*.example.com" of hosts is used in Certificate Pinning HOT 2
- Certificate Pinning disable opportunity. HOT 1
- toCanonicalHost() HOT 11
- API suggestion: `buildMockResponse { }` HOT 2
- Fix HttpOverHttp2Test flakes and bad cache behaviour HOT 1
- Should SSLContext construction be deferred during OkHttpClient construction HOT 2
- Unexpected random crashes with java.lang.IllegalStateException: Unbalanced enter/exit HOT 8
- HTTPS request throught Proxy not working (but working fine with java.net) HOT 10
- Flaky test report
- IOException with "Connection reset" message causes loss of requests HOT 3
- Connection pool biased towards slow connections HOT 5
- Please build a new release of version 5 with fix https://github.com/square/okhttp/issues/8154
- removeHeader is not removing header HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from okhttp.