Skip to content

Add targetHostIp option, support concurrent STA in Android #432

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

davidalo
Copy link

@davidalo davidalo commented Aug 13, 2025

Context
Android 12 introduced WiFi STA/STA concurrency, which allows supported devices to connect to more than one Wi-Fi network at the same time.
For example, when connecting to an IoT device, an Android phone can be connected concurrently to both:

  • The primary internet-providing Wi-Fi network

  • A local-only IoT Wi-Fi network

From the Android documentation:

The concurrent local-only and internet connection function allows devices to connect to a local-only connection, such as a connection to an IoT device, concurrently with the primary internet-providing network.

Problem
In the current implementation (master branch), the wifiOnly option routes requests through the Wi-Fi interface. However, with STA/STA concurrency there may be multiple Wi-Fi interfaces, and Android can choose either of them. This can cause requests to be routed to the wrong network.

Solution
This PR introduces a new option, targetHostIp, which explicitly specifies the IP address of the device you want to send the request to. This ensures requests are routed to the correct interface when multiple Wi-Fi connections are active.

References
Similar functionality has been implemented in other libraries, e.g.: Rapsssito/react-native-tcp-socket#193

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

Successfully merging this pull request may close these issues.

1 participant