简体   繁体   中英

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM