Giter VIP home page Giter VIP logo

Comments (17)

galderz avatar galderz commented on May 17, 2024 2

Hi, I've been working on this. I've created a PR (#4674) to get some feedback. Thx

from okhttp.

distinctdan avatar distinctdan commented on May 17, 2024 1

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.

swankjesse avatar swankjesse commented on May 17, 2024

Requested upstream: https://code.google.com/p/android/issues/detail?id=56243

from okhttp.

DanielNovak avatar DanielNovak commented on May 17, 2024

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.

rtzoeller avatar rtzoeller commented on May 17, 2024

We are also running into issues with this. Do you know if any progress has been made on a workaround?

from okhttp.

swankjesse avatar swankjesse commented on May 17, 2024

Nothing at the moment. It's a difficult bug to fix because DNS is completely opaque in Java.

from okhttp.

czfyzy avatar czfyzy commented on May 17, 2024

see:http://stackoverflow.com/questions/693997/how-to-set-httpresponse-timeout-for-android-in-java/31643186#31643186

from okhttp.

swankjesse avatar swankjesse commented on May 17, 2024

Maybe we do DNS on a background thread? That’d probably be worth the cost, although potentially surprising.

from okhttp.

swankjesse avatar swankjesse commented on May 17, 2024

One more thing: now that our Dns interface is public, end-users can do this if they like.

from okhttp.

yschimke avatar yschimke commented on May 17, 2024

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

https://github.com/yschimke/oksocial/blob/master/src/main/kotlin/com/baulsupp/oksocial/network/NettyDns.kt

from okhttp.

swankjesse avatar swankjesse commented on May 17, 2024

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.

yschimke avatar yschimke commented on May 17, 2024

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.

charanpanchagnula avatar charanpanchagnula commented on May 17, 2024

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

yschimke avatar yschimke commented on May 17, 2024

Dupe of #5042?

from okhttp.

swankjesse avatar swankjesse commented on May 17, 2024

Yep, these are mutually redundant.

from okhttp.

yschimke avatar yschimke commented on May 17, 2024

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.

yschimke avatar yschimke commented on May 17, 2024

It would probably be more correct to use the AsyncDns implementation

https://github.com/square/okhttp/blob/6b91ea468c6b2931f9092232d8ebcf61076023ff/okhttp/src/jvmMain/kotlin/okhttp3/AsyncDns.kt

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.