0

The following code sets up a repetitive alarm to send a heartbeat to a server every five minutes.

if (!isHeartBeating(context)) {
            alarmMgr = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
            Intent alarm_intent = new Intent(Globals.BC_HEARTBEAT);
            alarmIntent = PendingIntent.getBroadcast(context, 0, alarm_intent, 0);
            alarmMgr.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
                    SystemClock.elapsedRealtime() + fiveminutes,
                    fiveminutes, alarmIntent);
        }

I then leave the handset connected to power and with very good 4G coverage, and it does send heartbeats every five minutes sharp as intended. However, after a few hours (four or five) it stops sending. The reason is that the network interfaces suddenly disappear. This is what logcat shows:

07-26 13:28:46.690 889 889 E kickstart: ERROR: function: rx_data:517 Read/Write File descriptor returned error: No such device, error code -1

07-26 13:28:46.690 889 889 E kickstart: ERROR: function: main:302 Uploading Image using Sahara protocol failed

07-26 13:28:46.700 832 832 I kickstart-efsks: retval = 256

07-26 13:28:46.700 832 832 E kickstart-efsks: ERROR: ks return code was 256, something failed

07-26 13:28:46.700 832 832 E kickstart-efsks: Back from KS call, something went wrong, trying again

07-26 13:28:46.700 832 832 E kickstart-efsks:

07-26 13:28:46.750 695 781 D UsbHostManager: onUEvent(device) :: action = remove, devtype = usb_interface, device = null, product = 5c6/904c/0, type = 0/0/0, interface = 255/255/255, devpath = /devices/platform/msm_hsic_host/usb1/1-1/1-1:1.0

07-26 13:28:46.760 695 781 D UsbHostManager: onUEvent(device) :: action = remove, devtype = usb_interface, device = null, product = 5c6/904c/0, type = 0/0/0, interface = 255/255/255, devpath = /devices/platform/msm_hsic_host/usb1/1-1/1-1:1.1

07-26 13:28:46.770 195 664 W Netd : No subsystem found in netlink event

07-26 13:28:46.770 195 664 D NetlinkEvent: Unexpected netlink message. type=0x11

07-26 13:28:46.790 695 894 D Tethering: interfaceLinkStateChanged rmnet_usb0, false

07-26 13:28:46.790 695 894 D Tethering: interfaceStatusChanged rmnet_usb0, false

07-26 13:28:46.810 695 894 D Tethering: interfaceRemoved rmnet_usb0

07-26 13:28:46.810 695 894 E Tethering: attempting to remove unknown iface (rmnet_usb0), ignoring

07-26 13:28:46.810 695 894 D Vpn : interface Removed : interface = rmnet_usb0

07-26 13:28:46.810 695 781 D UsbHostManager: onUEvent(device) :: action = remove, devtype = usb_interface, device = null, product = 5c6/904c/0, type = 0/0/0, interface = 255/255/255, devpath = /devices/platform/msm_hsic_host/usb1/1-1/1-1:1.2

07-26 13:28:46.820 695 781 D UsbHostManager: onUEvent(device) :: action = remove, devtype = usb_interface, device = null, product = 5c6/904c/0, type = 0/0/0, interface = 255/255/255, devpath = /devices/platform/msm_hsic_host/usb1/1-1/1-1:1.3

07-26 13:28:46.830 695 781 D UsbHostManager: onUEvent(device) :: action = remove, devtype = usb_interface, device = null, product = 5c6/904c/0, type = 0/0/0, interface = 255/254/255, devpath = /devices/platform/msm_hsic_host/usb1/1-1/1-1:1.4

07-26 13:28:46.830 695 781 D UsbHostManager: onUEvent(device) :: action = remove, devtype = usb_interface, device = null, product = 5c6/904c/0, type = 0/0/0, interface = 255/255/255, devpath = /devices/platform/msm_hsic_host/usb1/1-1/1-1:1.5

07-26 13:28:47.711 832 832 E kickstart-efsks: File '/dev/efs_bridge' was not found

07-26 13:28:47.711 832 832 E kickstart-efsks: /dev/efs_bridge does not exist.

07-26 13:28:48.101 195 664 W Netd : No subsystem found in netlink event

This looks like a major problem with the efs / usb mappings, and it only gets fixed after a re-start (flight mode on / off does not solve it). This does not happen when my app is not running, so it is caused by the app, though logcat shows nothing about my app anywhere around the time when this problem happens.

Any clue on how to debug this further to find the root of the problem?

PS: this log is from an old Samsung Galaxy S4 loaded with Android 4.3 , but this issue is happening also in other handsets with newer Android versions.

Community
  • 1
  • 1
juan noguera
  • 135
  • 2
  • 3
  • 10
  • Please provide more details. "Error: Failed to connect to /ip_address:port" is not name of Exception class. What is the actual error? How do you connect to server? Are you keeping the connection open (perhaps by using TCP keep-alive) or reconnecting each time? – user1643723 Jul 25 '17 at 00:47
  • The heartbeat (keep-alive) is a just an HTTP post to a server. I use retrofit over okhttp3 for this. I think that it reconnects everytime. – juan noguera Jul 25 '17 at 11:07
  • In the last test, the UE stopped sending during the night. This morning when I checked, the UE had lost its ip address in rmnet_usb0 interface, which is the one that connects to the default APN (used for Internet). I do not know why the UE is loosing the connection to this APN after a few hours. I have been profiling it for serveral hours this morning and there is no sign of memory leaks. I will try to get a logcat the next time this happens and share the relevant parts . – juan noguera Jul 25 '17 at 11:19
  • Sadly I don't have ready solution for you, but this sounds suspiciously like [DHCP issues](https://www.net.princeton.edu/android/android-stops-renewing-lease-keeps-using-IP-address-11236.html) (not necessarily the ones, described at the link, just general type of problems). The timing, IP loss etc. Maybe running an on-device sniffer around the time of predicted loss might help. – user1643723 Jul 25 '17 at 17:02
  • Thanks anyway. I updated the main body with default logcat output. Unfortunately, I cannot see in logcat what is causing this problem. – juan noguera Jul 26 '17 at 14:15

0 Answers0