Search code examples
androidsmack

On Android loss of WiFi connection does not lead to connection termination, but loss of mobile data network does. Why?


  • I am testing loss of network connection on android Galaxy S6 for my app.
  • I have two types of network 1) WIFI 2) mobile data
  • I establish a stream from device to server.
  • I use SMACK to establish the stream

  • I do two types of tests:

  • First I disabled WIFi before I launch my app. That means I only launch with mobile data enabled.

  • While in app, I switch to "Airplane Mode"
  • I observe my stream is close with error "Connection Closed on error" triggered by loss of network.

  • Second, I launch my app only with WIFI (I disables mobile data before launching app)
  • I repeat the same test case as above switching to "Airplane Mode"
  • But this time, the app/smack library did not detect loss of connection and I see not errors related to network.

Can you please explain the discrepancy?


Solution

  • Some Android kernels do not close the TCP socket in certain cases. Also it depends on how Airplane mode is concretely implemented.