2 Android devices blocking each others HTTP requests in same LAN - android

I have an Android app which is continuously downloading JSON files with status updates, and if needed it downloads corresponding zip files. What the application exactly does is irrelevant.
The problem is that if i have 2 devices running in the same LAN with the app installed, one app blocks HTTP request of the other one. So one app is running fine, the other one is constantly running into timeouts for exactly the same request (only the token in the GET parameter differs).
When i turn of the "working" device, the block is released - and the other device is running fine, without timeouts.
Myself i think it is an routing issue.
Does anybody know how to prevent this?
In my app i connect through Volley. I am using a singleton for the connection pool - build by the documentation you can find on https://developer.android.com/training/volley/requestqueue.html

This is not likely a client issue (your Android app). You should check your server implementation first.
Singleton or transient RequestQueue in Android app doesn't matter. Because number of concurrent GET requests to server depends on number of devices you have.

There seems to be an issue with android devices and timestamps that are used for the connection. I found the solution to the problem.
Search the solution in the TCP protocol / settings.

Related

Flutter `SocketException: HTTP connection timed out` sometimes when app start

I have a Flutter application and it makes some HTTP requests to my server. However, once in a while (not sure when, but I have seen it several times a day), when I open my app, the HTTP requests that happen during the first few seconds all report the error of SocketException: HTTP connection timed out (the source code that throws this seems to be here). However, after the first few seconds, other HTTP requests will succeed.
I have tried hard reproducing it but failed. Usually this bug happens, when I put my phone there for some time and then open the app (but it is not a thing for sure; also in many cases such behavior will not trigger the bug). If the bug happens, and I close the app and reopen it immediately, it will run very well and the bug will not happen again.
I have also used Wireshark to try to look at the network packages. However, when I setup the environment as "my app (in my phone) connects to my computer with development server using wifi and http", that bug seems to never appear again. Only with the production environment "my app (in my phone) connects to a server in the cloud using https" that this bug happens. But in that case I cannot use Wireshark to look into the packages.
I know I do not provide a reproducible sample, but I really cannot find out any clues. I even cannot stably reproduce it :(
I would truly appreciate it for any suggestions!!!
I had faced this issue in one of my initial projects, which usually happens with HTTP package, I'll recommend you to try this package:
https://pub.dev/packages/dio
And if you are an android developer then you may know it is the best combination to use dio with retrofit
https://pub.dev/packages/retrofit

.NET Web service (asmx) which is back end for Android devices does not serve devices from the same IP

Here is the deal... I have created a web service (asmx) which is running a long time consuming procedure in a class and returns the result. The web service is served in my local windows 10 IIS connected to the router with port forwarding. The android device connected to the same router (as the iis) accesses the web service in IIS with the outside IP (my router's IP on the internet - for checking purposes). I noticed that the first device accessing the service is served ok but the second delays big time to be served. Checking the net I found that there is a restriction in serving devices from the same IP. I disconnected one of the devices from the WLAN and everything worked as a charm. Both devices were served in the same time. How can I overcome this problem?
Thanks in advance
Searching the Internet I discovered (there are huge chances that I may be wrong) that this might have to do with the default behavior of DotNet framework which locks the session to the first in first served device:
ASP.NET application to serve multiple requests from a single process
and
Android http connection - multiple devices cannot connect the same server
I suppose that my IIS assumes that the attempt to hit the web service from the second device is another attempt by the same device. I also suppose that it assumes the device to be the same device since it is the same application with the same internal environment hitting the web service and it can't tell that they are two different devices. I tried to reproduce this error and check if I am right by hitting the IP reporting page in IIS from two different tabs of the Mozzila Developer edition browser but it works ok (so I am not sure if it is a session issue). I also found a report that the issue is present only in android devices but it was not clear enough if the server was IIS... The solution mentioned was "incorrect flag on the tcp kernel settings - Reuse connection". Does it tell anything to anyone of you?
If the session lock is indeed the problem is there a solution to make IIS distinguish that there are two devices indeed? Is there a setting in IIS that would change this default behavior of DotNet?
I am sure there is a solution (if indeed the issue is session lock) because I uploaded my code to an on-line server and it works perfect when hitting it from two Android devices. So either it is not a session lock issue or there is a setting that it changes this behavior of DotNet in IIS... Is anyone aware of such a setting?

Android http connection - multiple devices cannot connect the same server

I really need help here...
I have a simple Android application that connects to my sever to fetch data over HTTPS.
Everything is working fine up until i connected to the same server from another device (iOS or Android). I am starting to get timeouts or connection refused or other errors depending on the library that I use (sometimes SSL handshake)
I tried 2 android app on the same router - fails
I tried Volley, Retrofit, plain http library - fails
if one device is connected via cellular network and one on wifi, it is working fine. However, i have seen cases that it fails even using 2 devices connected to cellular network and not wifi.
It is easy to reproduce. one app is working fine. as soon as i do an operation on the other device. the first app will not be able to connect.
iOS app using the same api/server is working fine. no failures
I ran wireshark on the android app during failure and received the following:
70 47.073286 10.0.0.1 10.0.0.138 ICMP 120 Destination unreachable (Port unreachable)
Seems like port issues. I am not sure anymore if this is a server issue or a client issue.. iOS app works fine. no issues. Only Android.
I tried:
System.setProperty("http.keepAlive", "false");
I tried setting an http header "connection :close" nothing works...
Any idea would be appreciated...
Same problem here . When my ios device connect to allstar heroes or fun run application the android device cant connect anymore . I cant find s fix for that . My router is tp link dir 615 . Maybe the problem is frpm router .
At the end of the day, it was server side issue. the IT guy gave me the following info: "incorrect flag on the tcp kernel settings" "Reuse connection" that is all I have for you. hope it can help someone else
I had the same problem. The issue seemed to be when the app tried to access ports in TIME_CLOSE here is a great explanation how this happen, changing the tcp kernel to Reuse connection, might solve the problem since the server will try to re-use those connection in TIME_CLOSE again. but it must be a solution from the client side to avoid the connection to get stuck. in my case I was trying to create connection from multiples activities and i guess they, somehow, competed for opening and closing the connections, i solved the issue using a single activity to make the connection to the server.
hope this is useful to someone.
Had exact the same issue and spent a lot of time investigating, nothing helped including "Reuse connection" flag, tried also to disable tcp_timestamp, tcp_tw_reuse, tcp_tw_recycle and enable vm safe mode for the app as suggested here:
https://github.com/square/okhttp/issues/903
https://github.com/square/okhttp/issues/1037
https://github.com/square/okhttp/issues/1518
but all in vein.
Further more, the very strange thing was that I had two different instances/servers which I made exactly the same in order to track down the issue and one server didn't have any issues.
So in the end:
Instance reboot solved problem with connections.
(or just need to restart networking service)
(c) My server/instance admin

Why do i get time out in bluemix sample app?

I have followed the tutorial of bluemix that is called bluelist. See here: http://www.ibm.com/developerworks/library/mo-android-mobiledata-app/#N1021F
I have installed all required libs and i have installed everything in the bluemix side.
I get error IBMBLUEMIX-0554E: timeout expired before connection could be established.
any solutions?
This could be caused by a couple issues.
You could be attempting to access an internal test zone (AKA stage1) without being in the internal network. Make sure there is not stage1 present in your app route.
Your phone/emulator may not be connected to a network properly. Please be sure that your test device is connected to the internet via data service or local connection. You can try running a speed test on that device if in doubt. Some custom created emulators can also have issues of their own. Try using a physical device if possible.
You may be on a network using a proxy server. I have heard of timeout issues when using a proxy. You may need to use a network that does not utilize a proxy.
This issue comes intermittently some times due to network/connectivity issue.Also you need to Verify that your applicationId, applicationSecret, and applicationRoute are correct.You can go to the Overview of your Mobile Cloud Service application on ACE to find your applicationId and Route. The applicationSecret is on the MAS portion of the ACE UI for your application.
Similar issue was reported already:
https://developer.ibm.com/answers/questions/26821/getting-time-out-error-while-conencting-to-mobile-cloud-bluemix-application.html

How to detect the cause for HUGE data usage when my app in background

We have an Android app with over a million active users. We recently started receiving feedbacks from users complaining that our app consumes huge amount of network data when in background (around 0.5-3 gigabytes in a week).
The app doesn't have any operations in the background except for the push notifications receiver which doesn't have any network calls. the data consumption on the background should be less than 10 megabytes for a week for sure.
Is there a code I can use to help me detect the cause for this data consumption when my app is in background?
Is there a way to limit data access from all SDKs when my app is in background?
In general, what's the best way to approach such a problem?
Thanks
Update:
In our case we found eventually that the source of the problem was from an SDK we integrated with the app.
If you have the same issue, I suggest you look closely at all your 3rd party code in the app, especially new libraries you added.
Second, check all the services that your app define in the manifest, look closely if any of those services can be the source for this problem.
Third, look for places in the app that use network operation with a re-try mechanism, there could be an infinite "while loop" trying to send some data to a server (maybe some sort of reporting or analytics).
You need to inspect the traffic coming over the wire from your devices. You will need one computer and your device connected to the same local network.
Set up a debugging proxy like Fiddler on a machine on your local network and note its IP address. This assumes your app communicates via HTTP.
Connect your test device(s) via WiFi to the same network as your debugging machine.
Configure your Android devices to use a proxy that points to your debugging machine.
Now you will be able to inspect all requests originating from the device(s). Presumably you will have to leave them running for some time to replicate the problem of some kind of periodic background service running and downloading data. However, I can tell you now that push notifications themselves are not causing 3GB of data on a single device.
You can write code for count the data usage as follows.
recived = TrafficStats.getUidRxBytes(uid);// uid is your appID
send = TrafficStats.getUidTxBytes(uid);
TrafficStats.getMobileRxBytes();
TrafficStats.getMobileTxBytes();
TrafficStats.getTotalRxBytes();
TrafficStats.getTotalTxBytes();
and there is good answer you can find here..
App data usage finding

Categories

Resources