[TIMOB-26737] WiFi network connection issue via a TCP socket to a local IP address (e.g. 192.168.1.1).
GitHub Issue | n/a |
---|---|
Type | Story |
Priority | None |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2019-04-12T20:41:50.000+0000 |
Affected Version/s | Release 7.5.0 |
Fix Version/s | n/a |
Components | Android |
Labels | n/a |
Reporter | Motiur Rahman |
Assignee | Unknown |
Created | 2019-01-16T11:04:12.000+0000 |
Updated | 2019-04-12T20:41:50.000+0000 |
Description
For a device configuration application, which uses a WiFi access point on the hardware to be configured, we're having a problem with some Android devices that appear to use the 3G network instead of the WiFi network to connect via a TCP socket to a local IP address (e.g. 192.168.1.1).
In the device, in question, the WiFi network is marked with an active connection but without internet connectivity.
We would need to understand if it is a problem that depends on the device or the SDK Titanium, and if it is possible to declare what type of connectivity to use to open the TCP client connection (Titanium.Network.Socket.TCP)
var socket = Ti.Network.Socket.createTCP({
host: "192.168.1.1",
port: 7000,
timeout: 1000,
connected: function (e)
{
console.log("Socket OPEN");
},
error: function (e)
{
console.error(e.error);
}
});
The problem seems to be derived from the fact that if the device is connected to a wifi network without internet, the TCP socket connections tremble the SDK are opened through the 3G network (or are not opened) instead of via the WiFi network even if you try to connect to a local IP (eg 192.168.1.1).
To try to reproduce the problem the procedure should be as follows:
1. I connect to a wifi network without internet with a server socket listening to the 192.168.1.1 address. The device must also be connected to a mobile network.
2. Through the app I try to open the socket as indicated in the sample code
The cases we have detected are the following:
- in some devices, the connection to the local IP on the wifi network without internet is without problems even if you are connected to the mobile network at the same time
- in other devices, the connection to the local IP of the network without internet fails when the device is also on the mobile network
- on the same device that presents problems, disabling the mobile data network on the device the connection to the local IP on the network without internet seems to work correctly
One of the devices that present the problem is the following:
Blackview BV9500 (Android 8.1)
First, let's pretend we're talking about a computer/PC that has 2 network cards. One network card is connected to wired Ethernet. The other network card is connected to WIFI. In this scenario, each network card is expected to connect to different "subnets". In your case, your local WIFI has a subnet of "192.168.x.x". For your wired Ethernet card, ideally it should connect to a different subnet. If your wired Ethernet was connected to a different network with the same "192.168.x.x" subnet, then your PC may never use it because it sees that both network cards are connected to the same subnet and may choose one over the other. I think you are running into a similar scenario here. Perhaps some of your phones will use its 3G network as a 192.168.x.x subnet as well, kind of like how a hotspot works. Try changing your local WIFI access point to use a different subnet to prove that this is case.
Hello I asked for assistance with this problem, and I think the issue has been opened somewhat out of context. The problem comes with an app I'm developing for the configuration of an IoT device (gate open board) through connection to the WiFi access point of the IoT board. I can not change the network settings on the board. How can I check if the mobile network uses the same subnet?
There are free apps you can download from Google Play that'll display info about every network the device is connected to. Perhaps you might find info under your device's "Network & Internet" settings screen too? The reason why I think you have subnet collision is because you said the device will correctly connect to IoT device when disabling the mobile network. When opening a socket in native code, you really only set the IP address and port number. The operating system will then select which network device to connect to, and that's based on the IP address' subnet mask. I haven't tried this before, but perhaps you should try connecting to your IoT device by mac address instead of by IP address?
Also check if your device has hotspot or tethering enabled.
Hello As for the connection via mac-address is not possible because we can not know the mac-address of the device before, while the ip is static. The devices on which there were problems are of our customer, I arrange to run tests with network analysis app that I selected in recent days so as to get more details.