Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple inconsistencies in lib behavior (Android) #87

Closed
dimgrav opened this issue May 29, 2020 · 11 comments · Fixed by #115
Closed

Multiple inconsistencies in lib behavior (Android) #87

dimgrav opened this issue May 29, 2020 · 11 comments · Fixed by #115
Labels
android bug Something isn't working stale

Comments

@dimgrav
Copy link

dimgrav commented May 29, 2020

Tested on React Native (Android only):

  • 0.59.8
  • 0.60.3
  • 0.62.2

We are trying to integrate this library in a production level. So far, we've stumbled upon numerous issues, that do not appear to have been resolved in version 4.1.0.

Xiaomi Redmi Note 8 Pro - MIUI version 11.0.3.0 (based on Android P)

  • Wifi permission request loop that breaks randomly (with or without user interaction)
  • Connects to Wifi with internet connectivity, but cannot perform external API requests

Huawei P30 Lite - EMUI version 9.1.0 (based on Android P)

  • Connects to Wifi with internet connectivity inconsistently
  • Cannot connect to IOT device in the same WLAN

Xiaomi A2 Lite - Android One (Android Q)

  • Connects to Wifi consistently, always without internet connectivity

Example usage:

const connect = () => {
  WifiManager.forceWifiUsage(true);
  WifiManager.connectToProtectedSSID(ssid, password, false)
    .then(() => {
      // do stuff
    })
    .catch(() => {
      // handle error
    })
    .finally(() => WifiManager.forceWifiUsage(false));
};

Based on the information above, can you point me to a certain direction as to what the issue may be?

@dimgrav dimgrav changed the title Multiple inconsistencies in app behavior (Android) Multiple inconsistencies in lib behavior (Android) May 29, 2020
@Rapsssito Rapsssito added android bug Something isn't working labels Jun 1, 2020
@Rapsssito
Copy link
Collaborator

Rapsssito commented Jun 1, 2020

@dimgrav, looks like forceWifiUsage() causes some connectivity issues (see #76).
If you are using a TCP connection to communicate with your IoT devices, a possible workaround is react-native-tcp-socket, it allows you to bind your socket to an specific interface (ethernet, wifi, cellular, etc.) without forcing the whole app to use the WiFi connection.

Disclaimer: I am the creator and mantainer of react-native-tcp-socket

@eliaslecomte
Copy link
Collaborator

You have to connect first, then call WifiManager.forceWifiUsage(true);.
I think I'll add something to the readme to make this more clear.

The loop issue is actually a firmware bug, it's up to Oneplus and Xiaomi to fix that :-/.

@nitin992503
Copy link

Hello @eliaslecomte,
In I am trying to connect to wifi of esp32 from android using this library. But it keeps disconnecting. WiFi first connects then a pop appears and then WiFi disconnects and pop disappear too. This cycle keeps going on and after some time wifi connects to my home network and then a pop up appear with failue message . Do you think this is also a firnware bug ?

@eliaslecomte
Copy link
Collaborator

Hello @eliaslecomte,
In I am trying to connect to wifi of esp32 from android using this library. But it keeps disconnecting. WiFi first connects then a pop appears and then WiFi disconnects and pop disappear too. This cycle keeps going on and after some time wifi connects to my home network and then a pop up appear with failue message . Do you think this is also a firnware bug ?

What smartphone brand/model are you using?

@nitin992503
Copy link

I am using Oneplus for testing purposes

@nitin992503
Copy link

Thanks for your quick reply

@qcasey
Copy link

qcasey commented Jun 16, 2020

I think the consensus is that this is OnePlus's issue to solve, see the thread here: ThanosFisherman/WifiUtils#63

In the meantime, you may want to look into the OTA updates for your device, some people claim it's fixed in beta versions:

https://issuetracker.google.com/issues/143549613#comment26

I haven't tried any, since my OP7Pro is my daily

@nitin992503
Copy link

Thank you for your comment @qcasey , I have the same issue as this one ThanosFisherman/WifiUtils#63 . The current version of oxygen OS in my phone is 10.3.4 and in the issuetracker somebody mentioned the fix in 10.5.7, this update is not yet available to me. So i guess i will just have to wait until this update is made available.

@github-actions
Copy link

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community attention? This issue may be closed if no further activity occurs.

@github-actions github-actions bot added the stale label Jul 22, 2020
@jk89gr
Copy link

jk89gr commented Jul 24, 2020

Hello @eliaslecomte ,
since this issue is still open, I though I might ask here, instead of raising a separate one.

The behavior that @dimgrav described:

Connects to Wifi consistently, always without internet connectivity

still occurs on 4.2.0.

Is this supposed to be fixed by now? If so, then i can only suspect that it's bad implementation from my end, so an example usage would be very much appreciated.

You have to connect first, then call WifiManager.forceWifiUsage(true);.
I think I'll add something to the readme to make this more clear.

@github-actions github-actions bot closed this as completed Aug 1, 2020
@eliaslecomte
Copy link
Collaborator

eliaslecomte commented Aug 4, 2020

Yes it should be fixed.

What's the code you are currently using?

try {
  await WifiManager.connectToProtectedSSID(ssid, password, false);
  await WifiManager.forceWifiUsage(true)
  // execute api calls here
} finally {
  await WifiManager.forceWifiUsage(false))
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android bug Something isn't working stale
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants