4

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)

  1. I tried 2 android app on the same router - fails

  2. I tried Volley, Retrofit, plain http library - fails

  3. 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.

  4. 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.

  5. iOS app using the same api/server is working fine. no failures

  6. 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...

BSavaliya
  • 809
  • 1
  • 16
  • 26
Oved Yavine
  • 442
  • 6
  • 12
  • This is a server issue. Your server is refusing connection to the second client, since this is https connection and I am assuming that you need to login to the server with some user credentials. If you have control over the server architecture I would start there – faljbour Feb 20 '15 at 07:59
  • That is what i though initially. But, why does the iOS app works flawlessly? – Oved Yavine Feb 20 '15 at 08:09
  • did you try the iOS app on two different devices with the same credentials and it worked fine. – faljbour Feb 20 '15 at 08:12
  • yes. we do not have an issue with the iOS app whatsoever. – Oved Yavine Feb 20 '15 at 08:32
  • Do not use `Connection ,close`. It may cause a problem. – Anggrayudi H Feb 20 '15 at 09:06
  • To keep those that are interested in the loop. This is indeed a server problem and a very weird one as well. This issue is reproduced on a browser as well. I open the website on the browser in Android (works), I open the same web site on the browser in iPhone (works), go back to the Android and refresh the site, and it gets stuck and timeout. I will post a resolution once I have it, But, this is definitely not an Android code issue – Oved Yavine Feb 23 '15 at 11:07
  • @OvedYavine did you manage to fix that problem? We are running our web-services on GoDaddy and having same problem you have. Whenever i try to call web-services from 2 different device on android, one of them starts failing with SocketTimeoutException and cannot reset itself for a minute or more. This is kinda frustrating, does it mean we need to change our server side and carry stuff to somewhere else? – denizt Sep 04 '16 at 16:29
  • @denizt yes. See my comment on this page. "in my case 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" – Oved Yavine Sep 06 '16 at 05:06
  • @OvedYavine so you guys change that flag on kernel config file of server? or you just use a new server? Thanks for the information. – denizt Sep 07 '16 at 06:11

4 Answers4

0

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 .

naby
  • 1
  • in my case 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 – Oved Yavine Mar 22 '15 at 07:43
0

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

Oved Yavine
  • 442
  • 6
  • 12
0

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.

Community
  • 1
  • 1
Alfr3
  • 11
  • 3
0

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:

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

GregoryK
  • 3,011
  • 1
  • 27
  • 26