Describe the bug
Hello to all,
I have an issue with Detox and Android SDK 29 on my local development server. This bug is due to Android cleartext configs: https://developer.android.com/training/articles/security-config. If I configure Detox as shown in the example, it works fine but the app cannot make requests to my local dev server on my computer.
To Reproduce
To reproduce this bug, it very simple.
Steps to reproduce:
<domain includeSubdomains="true">192.168.178.63</domain>
It looks like this after:
`
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">10.0.2.2</domain>
<domain includeSubdomains="true">localhost</domain>
<domain includeSubdomains="true">192.168.178.63</domain>
</domain-config>
`
Expected behavior
I expected Detox to work correctly and the Android cleartext requests to work as well. Instead what happens is that: Detox will timeout and the Android cleartext requests will work fine too.
Environment (please complete the following information):
jest-circus Any update on this? Even i am facing the same issue.
Allowing for clear-text configuration should in no way block network traffic, be it "clear" or secured. You need to double check what's blocking the traffic. If you need more confidence as to whether clear-text traffic configuration is related to this or not, try to temporarily set usesCleartextTraffic=true globally (see here)
Hello @d4vidi,
Allowing for clear-text configuration should in no way block network traffic, be it "clear" or secured. You need to double check what's blocking the traffic. If you need more confidence as to whether clear-text traffic configuration is related to this or not, try to temporarily set
usesCleartextTraffic=trueglobally (see here)
That's what I tried before but the problem is that if I apply
usesCleartextTraffic=true
Detox won't connect to the server but the app will work fine (i.e connect to my local dev server)
@franznkemaka could you possibly set up a super-simple demo app where this is reproduced? It's hard to wrap my head around why this would happen, and logs won't be helpful in this case, imo
@franznkemaka could you possibly set up a super-simple demo app where this is reproduced? It's hard to wrap my head around why this would happen, and logs won't be helpful in this case, imo
Ok @d4vidi I'll create a demo repo, once done I'll reference it here.
Great, thanks
Hi to all,
I cloned the Detox demo-react-native, it works very well using usesCleartextTraffic=true with React Native 0.62.2 only. When I upgraded to React Native 0.63.2, it doesn't work anymore.
This means that usesCleartextTraffic=true has no effect with React Native 0.63.2.
This is therefore the last solution , using
android:networkSecurityConfig="@xml/network_security_config"
surprisingly it works when I add my IPv4 address in network_security_config.xml in the demo project
It looks like this finally
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">10.0.2.2</domain>
<domain includeSubdomains="true">10.0.3.2</domain>
<domain includeSubdomains="true">localhost</domain>
<domain includeSubdomains="true">192.168.178.63</domain>
</domain-config>
</network-security-config>
But it won't work in my project I wonder why. When I add my IPv4 address like this
<domain includeSubdomains="true">192.168.178.63</domain> The app is able to connect to the dev server but Detox localhost server won't work, hence resulting in a timeout. If I remove my IPv4 address, Detox is able to connect to their localhost server but my app won't be able to fetch using the localhost.
This means that the issue is a conflict between 192.168.178.63 and localhost of Detox.
Hope it can help to debug this @d4vidi
Hi @d4vidi,
please do have any update?
I managed to set usesCleartextTraffic=true when I investigated my logs
with adb logcat
I got
Detox : Network is busy
This means that when the connection is working with my local server, Detox is ubable to use the connection. That's why it is not working.
I decided to close this issue as it has nothing to do with neither Android API 29 nor clear-text traffic.
The issue is a conflict between my local dev server and the Detox localhost.
That is why reproducing the issue wasn't that easy.
If you get this issue, surely your app makes a lot of requests, in my case I had Socket.io so it kept making requests and hence Detox reporting Network is busy
I'm closing this issue in favor of #2327
Allowing for clear-text configuration should in no way block network traffic, be it "clear" or secured. You need to double check what's blocking the traffic. If you need more confidence as to whether clear-text traffic configuration is related to this or not, try to temporarily set
usesCleartextTraffic=trueglobally (see here)
@d4vidi You're right that was not the problem, please checkout the new issue #2327
Most helpful comment
Any update on this? Even i am facing the same issue.