Search code examples
javaandroidhttpnetwork-programmingcharles-proxy

Issue with android network


During the tests I see strange things. My android app is sending some data to the server, I set connect and read timeouts(for tests I did a very short timeout like 2-3 seconds) after an timeout reached (exception thrown) I’m closing connection(connection.disconnect()) But in Charles I see strange connection data:

  • sometimes connection kept alive
  • Connection duration from 14 seconds up to 30+ seconds
  • After I see in logs that connection timed out I still see in Charles like connection alive with icon of uploading There are few questions:
  • It’s can be because of Charles?
  • It’s can depend on servers config like client(app) closes connection and server for some reason think that connection still alive?
  • if it’s an android/Java “feature” how I can to close connection immediately?

Solution

  • After tests and investigation into the issue, I've found that Charles keeps alive the connection. Tested on local simple server which logs connection and as a result I saw that while there is no Charles connection has been closed after java's disconnect() and with Charles connection still alive until some timeout(think defined in Charles)