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

feat(Android): Add support for Android concurrent connections (multiple networks) #193

Merged
merged 4 commits into from
Jun 20, 2024

Conversation

smartmedev
Copy link
Contributor

Impovements on this forks

For apps targeting Android 12 (API level 31) or higher, devices that support concurrent peer-to-peer and internet connections can maintain simultaneous Wi-Fi connections to both the peer device and the primary internet-providing network, making the user experience more seamless.
We add support for Android concurrent connections, routing all data traffic to the peer-to-peer network connection selecting the correct network based on the host DHCP address or subnet address.
This change is essential to open a tcp socket and send data towards ioT devices that expose a WiFi network without internet access.
See: https://developer.android.com/about/versions/12/behavior-changes-12#concurrent-connections.

Executed tests

I've tested this changes on three devices - all works great:

  1. Google Pixel 8 - Android 14
  2. Samsung A22 - Android 13
  3. Redmi Note 7- Android 10

React Native version is 0.74.1

@vricosti
Copy link
Contributor

If nothings happens in the next weeks I will be tempted to start of a fork of this project but in the mean timeI will use the patch strategy: https://medium.com/@yusufsancakk/comprehensive-guide-to-patching-react-native-packages-f7f73836ce6c

@smartmedev
Copy link
Contributor Author

Hi @vricosti the project seem not maintained too much unfortunately. I've made my fork, and now i'm using that fork on my personal package.json.

"react-native-tcp-socket": "github:smartmedev/react-native-tcp-socket",

@smartmedev smartmedev requested a review from vricosti June 7, 2024 13:23
@Rapsssito
Copy link
Owner

@smartmedev, thanks for the PR! Sorry for the delay. Could you please remove the changes in README.md so I can merge the PR?

@smartmedev
Copy link
Contributor Author

Hi @Rapsssito ! I've just removed the changes from README.md so you can merge the PR

@Rapsssito Rapsssito changed the title Added support for Android concurrent connections (multiple networks) feat(Android): Add support for Android concurrent connections (multiple networks) Jun 20, 2024
@Rapsssito Rapsssito merged commit a2d1a79 into Rapsssito:master Jun 20, 2024
1 check failed
github-actions bot pushed a commit that referenced this pull request Jun 20, 2024
# [6.1.0](v6.0.6...v6.1.0) (2024-06-20)

### Features

* **Android:** Add support for Android concurrent connections (multiple networks) ([#193](#193)) ([a2d1a79](a2d1a79))
Copy link

🎉 This PR is included in version 6.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@dkruegerkj
Copy link

I can not get a connection to my peer-to-peer device while being connected to the network with internet access via Wifi.

Does the concurrent network behaviour only applies to have multiple connections using Wifi or also connections via Ethernet (USB adapter)? In my case I'm using a peer-to-peer connection to my external device using an ethernet-to-USB adapter. The device is giving IP address using a DHCP server.
While my phone has an active wifi connection, I can not connect to the socket on my external device using the device IP address. If I disconnect wifi, the device gets instantly connected to my phone.

Using Samsung Galaxy A13 and Huawei Mate 20 lite.

@smartmedev
Copy link
Contributor Author

Hi @dkruegerkj
Concurrent connections are meant over the same transport interface. WiFi over WiFi gave the problem, so this fix has been created for this.
The thing is that this fix should also works with different transport types, if correctly confirgured.
Important for you is to set correct values ​​in option configuration array.
First thing, be sure you specify the "interface" param with "ethernet" value if you are trying to connect to your device via ethernet, otherwise the code will search over the current active transport interface. In your case, for what you're saying is "wifi".
Also specify "host" param, if you don't specify or if you set "localhost" the code works as default, (I mean as if concurrent connections fixes is not present).

const options = {
  .....
  host: "192.169.0.101",
  interface: "ethernet",
  .....
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants