aboozaid / react-native-tethering

A React Native module for working with Wi-Fi and Hotspot. Compatible with Expo.
https://react-native-tethering.onrender.com/
MIT License
20 stars 2 forks source link

iot device's http server is not accessible on release build #28

Closed dongalor closed 4 months ago

dongalor commented 10 months ago

Hello there! I have this strange issue with accessing web server on iOt device on release build (running on expo works fine). After connecting to iOt's wifi with no internet access I can't make http requests to it. Tuning permissions in manifest like this https://gist.github.com/dongalor/55393a2af28f8a2d0d3f5f6aa32daec2

Thank you for any advice in advance :)

aboozaid commented 10 months ago

which android version do you use?

dongalor commented 10 months ago

which android version do you use?

Oh! I'm using Android 12 if you asking about my phone's android.. :)

aboozaid commented 10 months ago

I think this is out of the package scope but you have to ensure both devices are on the same network and get their IPs in order to communicate.

dongalor commented 10 months ago

I think this is out of the package scope but you have to ensure both devices are on the same network and get their IPs in order to communicate.

When I run my app via expo and connect with react-native-tethering to my iOt's wifi, I can do requests, but when I build release apk it doesn't work.

aboozaid commented 10 months ago

I think this is out of the package scope but you have to ensure both devices are on the same network and get their IPs in order to communicate.

When I run my app via expo and connect with react-native-tethering to my iOt's wifi, I can do requests, but when I build release apk it doesn't work.

I need some logs in order to debugging

mrsardana commented 10 months ago

I think this is out of the package scope but you have to ensure both devices are on the same network and get their IPs in order to communicate.

When I run my app via expo and connect with react-native-tethering to my iOt's wifi, I can do requests, but when I build release apk it doesn't work. @dongalor Use : (android:usesCleartextTraffic) The default value for apps that target API level 27 or lower is "true". Apps that target API level 28 or higher default to "false". When the attribute is set to "false", platform components, for example, HTTP and FTP stacks, refuse the app's requests to use cleartext traffic.

Add android:usesCleartextTraffic="true" in your manifest inside tag. This will resolve your issue.

dongalor commented 10 months ago

Thank you so much for help.

Add android:usesCleartextTraffic="true" in your manifest inside tag. This will resolve your issue.

So, I've added this to my android/app/src/main/AndroidManifest.xml

<application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="true" android:theme="@style/AppTheme" android:requestLegacyExternalStorage="true" android:usesCleartextTraffic="true">

Still not works, trying to do clean rebuild of my app.

Also, I've found some information about intent-filter config here: https://stackoverflow.com/questions/40543618/does-data-androidhost-www-calender-com-androidscheme-http-data-make-ap, is it possible that accessing http within these permissions might need something like this?

I've also added some security configs same way as described in similar problem of similar library: https://github.com/JuanSeBestia/react-native-wifi-reborn/issues/323

Still not working :(