简体   繁体   English

在Android上,WiFi连接丢失不会导致连接终止,但移动数据网络丢失会导致连接终止。 为什么?

[英]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. 我正在为我的应用测试android Galaxy S6的网络连接丢失。
  • I have two types of network 1) WIFI 2) mobile data 我有两种类型的网络1)WIFI 2)移动数据
  • I establish a stream from device to server. 我建立了从设备到服务器的流。
  • I use SMACK to establish the stream 我使用SMACK建立流

  • I do two types of tests: 我进行两种类型的测试:

  • First I disabled WIFi before I launch my app. 首先,我在启动应用程序之前禁用了WIFi。 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) 其次,我仅使用WIFI来启动我的应用程序(我会在启动应用程序之前禁用移动数据)
  • 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. 但是这次,app / smack库没有检测到连接丢失,我看不到与网络有关的错误。

Can you please explain the discrepancy? 你能解释这个差异吗?

Some Android kernels do not close the TCP socket in certain cases. 在某些情况下,某些Android内核不会关闭TCP套接字。 Also it depends on how Airplane mode is concretely implemented. 这也取决于飞机模式的具体实现方式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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