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
Related
I need assistance with my Ionic app.
It works on Android device using "#ionic-native/http": "^5.30.0"
The problem is very strange..
Let's say we have a simple username/password login form.
Initially we are using 4G to login and the login is successful (The problem is not only with the login)
We log out of the app and we see the same screen - the login form..
On the device itself we turn on the WiFi and connect to any network (with or without internet)
If we try to login with the connected network (if there's internet, the login will be successful)
We will not use the WiFi and we want to revert using 4G again as the first time.
We disconnect manually the WiFi
On login we will receive error: {"status":-3,"error":"Host could not be resolved: java.net.UnknownHostException: Unable to resolve host
Surely there is network connection, as I can minimize the application and browse the web, also connect to the server and make HTTP call to it.
This used to work before a couple of months when I was playing around with it..
I have the server domain in the NetworkSecurity.config
I have these permissions in my app.component.ts
this.androidPermissions.requestPermissions([
this.androidPermissions.PERMISSION.CAMERA,
this.androidPermissions.PERMISSION.CHANGE_NETWORK_STATE,
this.androidPermissions.PERMISSION.CHANGE_WIFI_STATE,
this.androidPermissions.PERMISSION.DUMP,
this.androidPermissions.PERMISSION.INTERNET,
this.androidPermissions.PERMISSION.MANAGE_EXTERNAL_STORAGE,
this.androidPermissions.PERMISSION.WRITE_EXTERNAL_STORAGE,
this.androidPermissions.PERMISSION.ACCESS_WIFI_STATE,
this.androidPermissions.PERMISSION.ACCESS_NETWORK_STATE,
this.androidPermissions.PERMISSION.ACCESS_BACKGROUND_LOCATION
]);
I have also enabled fast network switch from dev options.
I've read s lot in the web related to this problem but can't find a solution.
I've tried updating all packages, reinitializing the platform and removing the node modules
The behavior is consistent and can be reproduced every time.
After a lot of digging, I found out, that the problem was in a library I was using "WifiWizard2"and a parameter called "bindAll".......
There's a PR.. https://github.com/tripflex/WifiWizard2/pull/102
Hello there long time reader of Stack Overflow but first time poster,
I am a bit new to android development but we decided to build a Xamarin.Forms app which consumes our ASP.NET REST service. When running the app on an emulator on my computer, connected via ethernet, I am able to connect to the service. However, when running on a tablet or phone that is connected on our work wifi, the connection just hangs and times out.
Interesting enough, when the device is switched to mobile data it can connect to the endpoints again, and iPhones can connect to the endpoints on mobile data or wifi.
I'm curious what I'm missing here. Please let me know what you think or additional information I should include.
While this thread has been opened for some time, we have found our problem resolved: it was a mixture of our network support changing some settings on our routers (though I can unfortunately not remember what settings) and also our tablets do a system update.
I am not sure which of these factors was the cause of our success now but the issue is done. I just wanted to post this in case anyone else ran into something similar.
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?
Hi everyone I have a question for you. I have a project that is using xamarin forms and in this project we are using the signalr client. Whenever I switch from Wi-Fi to cellular data my signal are times out. However the weird thing is that no statechanged events ever fire on a client side not even the disconnect, and I can still send messages with the proxy to other clients but it doesn't receive messages from the other clients. I had a question last week where servicestack was timing out when I switched from Wi-Fi to mobile and the solution was to put a connection header in the request that was set to close. I tried that with the signalr connection but it doesn't work. I've also tried to use the project modernhttpclient and that doesn't work either. On the server side I've even tried saying the keepalive to know so that way it only uses the connection timeout and the disconnect timeout.
Some other weird information about this problem is that it doesn't happen on all Android devices. It seems to work on the Samsung and a different Android device possibly a Nexus device. The reason I know this is that my coworkers have these phones and it works perfectly fine for them. However my device, which is a samsung galaxy s6 edge comma does not work with the code that was implemented for reconnecting when did not work changes
I'm fairly new to Android so my question is how do we create an HttpListener on Android device? My task is to create a listener on one android device and request a contact number from second android device & send the data back n forth. Can any one help me?
E.g:
Android Device 1 (Containing Listener)
Android Device 2 (Client)
Requesting Url to Android Device 1: http://192.122.1.2:8888/GetContactDetail?id=2
Response Received: "111111111111"
Any suggestion on how to implement this scenario?
You can try using i-Jetty to run an a webserver on your first device: http://code.google.com/p/i-jetty/
If you have never created a web application before, you can do the development on a laptop and get your second device working with it. Then deploy the application onto i-jetty when its ready.
In practice this won't work since most networks (mobile and wifi) use NAT. NAT prevents inbound connections to device, which basically means that you can not run servers on mobile devices.
Your approach would only work if both devices are on same local network.
Update
You need to embedd a http server into your app: http://tjws.sourceforge.net/
This is what I did, thanks to #elevine suggestion, I was able to do it successfully but as suggested by #Peter Knego the limitations are still there. This will work on LAN without any problem.
Hope this helps someone.
http://codersapprentice.blogspot.com/2011/09/android-integrate-jetty-server-in-my.html