okhttp cellular and wifi problem
See original GitHub issueHi,
I’ve got problem OkHttpClient. Cellular data on, WIFI connected. Application reqests HTTPS and everything works perfect. When WIFI lose connection (still on) app link through cellular and works ok. The problem is when phone connect back to this WIFI {java.net.UnknownHostException: Unable to resolve host: No address associated with hostname}
The only solution is to restart app, but I try to do this using JobScheduler and it have to work in backgroud.
var vProtokoly : java.Util.List<Protocol> := new java.util.ArrayList<Protocol>;
var vUprawnienia : RemObjects.Elements.RTL.String;
var Wywolanie : Request;
var Odpowiedz : Response;
vProtokoly.add(Protocol.HTTP_1_1);
vUprawnienia := okhttp3.Credentials.basic('some', 'credentials');
Http := new OkHttpClient.Builder()
.connectTimeout(15,java.util.concurrent.TimeUnit.SECONDS)
.writeTimeout(20,java.util.concurrent.TimeUnit.SECONDS)
.readTimeout(20,java.util.concurrent.TimeUnit.SECONDS)
.retryOnConnectionFailure(false)
.protocols(vProtokoly)
.proxy(Proxy.NO_PROXY)
//.socketFactory(android.net.Network.getSocketFactory())
.build();
Http.ConnectionPool.evictAll;
Wywolanie := new okhttp3.Request.Builder().url(Parametry.Uri).header('Authorization',vUprawnienia).build();
Odpowiedz := Http.newCall(Wywolanie).execute;
Issue Analytics
- State:
- Created 4 years ago
- Comments:5
Top Results From Across the Web
Android Force OkHttp Request Over Mobile Network
My app has certain requests that must be sent over the cellular network (3G, LTE, 4G, not Wifi). I'm using Retrofit and OkHttp...
Read more >Android: Intercept on no internet connection | by Elye - Medium
So in this blog, I'll show how to setup no internet connection detection naturally in OkHttp, which only needs to be done once...
Read more >How can I fix an issue where multiple okhttp requests fail over ...
I am working on an app that pulls information from an API via JSON format. This one request has never been problematic: When...
Read more >Overview - OkHttp - Square Open Source
OkHttp perseveres when the network is troublesome: it will silently recover from common connection problems. If your service has multiple IP addresses, ...
Read more >DNS caches bogus entries [36989750] - Issue Tracker - Google
W/System.err( 983): at com.android.okhttp.internal.http.RouteSelector. ... The log shows you got on wifi, connected to cellular data and then
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
After some investigation found the problem
I had
android.net.ConnectivityManager.setProcessDefaultNetwork(currentConnection);
in on lostConnection of registerNetworkCallback. After removing this everything works perfect. Sorry and thank you
@LHeczko I am running into something similar using OKHttp and Retrofit. It also seems to be specific to a certain kind of device. I don’t know that we have any specific code set up in
lostConnection
orregisterNetworkCallbac
k though. Where would I look for this?