0

I have a strange issue. My app is using http to connect to a server. It works fine in many devices. However, in Xiaomi devices which has Android 9, it gives me this error:

Caused by java.io.IOException: Cleartext HTTP traffic to internet.vodafone.com.eg not permitted
       at com.android.okhttp.HttpHandler$CleartextURLFilter.checkURLPermitted(HttpHandler.java:142)
       at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:469)
       at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:418)
       at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:549)
       at com.google.firebase.perf.network.zzd.getResponseCode(zzd.java:81)
       at com.google.firebase.perf.network.zzb.getResponseCode(zzb.java:14)
       at com.android.volley.toolbox.HurlStack.executeRequest(HurlStack.java:96)
       at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:123)
       at com.android.volley.NetworkDispatcher.processRequest(NetworkDispatcher.java:131)
       at com.android.volley.NetworkDispatcher.processRequest(NetworkDispatcher.java:111)
       at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:90)

In the AndroidManifest.xml I have this:

 <application
        ...
        android:networkSecurityConfig="@xml/network_security_config"
        ...
  </application>

My network_security_config.xml file:

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <domain-config cleartextTrafficPermitted="true">
        <domain includeSubdomains="true">thebondnews.com</domain>
    </domain-config>
</network-security-config>

Also, I have all the permission to connect to the internet. It works fine in Many devices with android 9 Like Samsung galaxy s9/s9+ and Samsung galaxy s8/s8+ and many others.

The error message was copied from Firebase Crashlatics. What is strange is that my server domain is thebondnews.com but in the log, it says internet.vodafone.com.eg or sometimes notification.etisalat.com.eg and 10.10.10.1. It is like there is kinda redirection in their devices.

Can anyone help me how to solve it? or what shall I do?

Update 1: Could it be that I am only allowing my domain in network_security_config.xml and because of the redirection caused by their providers the connection fails?

AbdulelahAGR
  • 86
  • 1
  • 8
  • check this out --> https://stackoverflow.com/questions/45940861/android-8-cleartext-http-traffic-not-permitted – Wini Jan 02 '20 at 14:27
  • Hi Wini, I already checked it, but we have different problems. His issue is about android 8. And the accepted solution is already implemented in my app, yet the issue is still there only with Xiaomi devices which has Android 9. Other than Xiaomi devices, the app works perfectly. – AbdulelahAGR Jan 02 '20 at 14:32
  • _"What is strange is that my server domain is thebondnews.com but in the log, it says internet.vodafone.com.eg"_ Maybe related to advertisements? Does the site not have an API you can send requests to instead of trying to scrape its contents? – Michael Jan 02 '20 at 14:44
  • This is because **The internet package of that user has finished and the operator try to redirect him to internet package page** – Md. Asaduzzaman Jan 02 '20 at 14:52
  • Hi Michael, I only use AdMob ads with no mediation, and the links seem to be related to Telecom companies. – AbdulelahAGR Jan 02 '20 at 16:28
  • Hi Md. Asaduzzaman, hmm That is a reasonable answer. I think that is the issue as the links are related to Telecom company and internet providers. However, my users claimed that pictures in the app are not loading. I guess they are not aware of the truth that their internet package has finished or maybe is limited to specific websites. Like there is a facebook or WhatsApp internet packages... could that be a reason as well? – AbdulelahAGR Jan 02 '20 at 16:31
  • I also think so, It's totally related to internet package I believe – Md. Asaduzzaman Jan 02 '20 at 17:02
  • Were you able to find a solution? – RominaV Jul 02 '20 at 14:48
  • RominaV, It turns out that some Carriers proxy the connection, so I used a custom HurlStack which take into account when the user is connected to a proxy and add it to Volley. Also, my server is connecting with Cloudflare and Cloudflare seemed to block many of the proxied connections. So, I disabled security from Cloudflare and make custom firewall rules. – AbdulelahAGR Jul 02 '20 at 21:03

1 Answers1

0

As Md. Asaduzzaman said in the comments.

The internet package of that user has finished and the operator tries to redirect him to the internet package page.

So it was not an issue with the app. However, some users have a limited internet package with limited access to things like Facebook, WhatsApp, Instagram..etc.

Thus, when my app tries to connect to the server, it is being redirected by the internet provider to block the traffic.

AbdulelahAGR
  • 86
  • 1
  • 8