Most of times it works great but sometimes i'm having this error while trying to discover BLE devices:
02-12 18:00:41.952 16178-16339/com.icrealtime.allie W/BleRpcConnectionFactory﹕ Starting discovery
02-12 18:00:41.955 16178-16339/com.icrealtime.allie D/BluetoothAdapter﹕ STATE_ON
02-12 18:00:41.957 24342-18813/? D/BtGatt.GattService﹕ registerClient() - UUID=c4a4c56d-1d10-4615-9c8d-44971bc3d6e6
02-12 18:00:41.957 24342-24384/? E/bt_btif﹕ Register with GATT stack failed.
02-12 18:00:41.957 24342-24384/? E/bt_btif﹕ Register with GATT stack failed.
02-12 18:00:41.957 24342-24370/? D/BtGatt.GattService﹕ onClientRegistered() - UUID=c4a4c56d-1d10-4615-9c8d-44971bc3d6e6, clientIf=0
02-12 18:00:41.958 16178-16190/com.icrealtime.allie D/BluetoothLeScanner﹕ onClientRegistered() - status=133 clientIf=0
02-12 18:00:41.967 16178-16178/com.icrealtime.allie E/BleRpcConnectionFactory﹕ BLE SCAN FAILED: 2
error code 2 stands for https://developer.android.com/reference/android/bluetooth/le/ScanCallback.html#SCAN_FAILED_APPLICATION_REGISTRATION_FAILED
It seems to be internal android issue, but it can be affected by my code doing something wrong. What can be the reason and how to walkaround it?
PS. Nexus 9, Android 6.0.1