Android BLE: “Scan failed, reason app registration failed for UUID”
I am developing an application using the RxAndroidBle
library that performs BLE scans regularly about every 30 seconds, and some BLE operations every minute or so. After a couple of hours, usually between 5 and 24h, the scan stops working. Every time a scan is supposed to be started, I get:
09-05 09:08:37.160 8160-8160/myapp D/BluetoothAdapter: startLeScan(): null
09-05 09:08:37.165 8160-8160/myapp D/BluetoothAdapter: STATE_ON
09-05 09:08:37.165 8160-8160/myapp D/BluetoothAdapter: STATE_ON
09-05 09:08:37.165 8160-8160/myapp D/BluetoothLeScanner: Start Scan
09-05 09:08:37.165 8160-8160/myapp D/BluetoothAdapter: STATE_ON
09-05 09:08:37.165 8160-8160/myapp D/BluetoothAdapter: STATE_ON
09-05 09:08:37.170 8160-8160/myapp D/BluetoothAdapter: STATE_ON
09-05 09:08:37.170 8160-8160/myapp D/BluetoothAdapter: STATE_ON
09-05 09:08:37.210 8160-12850/myapp D/BluetoothLeScanner: onClientRegistered() - status=133 clientIf=0
09-05 09:08:37.210 8160-12850/myapp D/BluetoothLeScanner: Registration failed, unregister clientIf = 0
09-05 09:08:37.215 8160-8160/myapp D/BluetoothLeScanner: Scan failed, reason app registration failed for UUID = 4c321920-a2b7-449a-bc24-ea4361f7a255
09-05 09:08:44.150 8160-8160/myapp V/myapp.debug: unsubscribing scan
09-05 09:08:44.150 8160-8160/myapp V/myapp.debug: Clearing scan subscription
09-05 09:08:44.150 8160-8160/myapp D/BluetoothAdapter: stopLeScan()
09-05 09:08:44.150 8160-8160/myapp D/BluetoothAdapter: STATE_ON
09-05 09:08:44.155 8160-8160/myapp D/BluetoothAdapter: STATE_ON
09-05 09:08:44.155 8160-8160/myapp D/BluetoothAdapter: STATE_ON
09-05 09:08:44.155 8160-8160/myapp D/BluetoothAdapter: STATE_ON
09-05 09:08:44.155 8160-8160/myapp D/BluetoothLeScanner: could not find callback wrapper
Does anyone have any idea of what causes this problem or what can be done to fix it?
android bluetooth bluetooth-lowenergy android-bluetooth rxandroidble
add a comment |
I am developing an application using the RxAndroidBle
library that performs BLE scans regularly about every 30 seconds, and some BLE operations every minute or so. After a couple of hours, usually between 5 and 24h, the scan stops working. Every time a scan is supposed to be started, I get:
09-05 09:08:37.160 8160-8160/myapp D/BluetoothAdapter: startLeScan(): null
09-05 09:08:37.165 8160-8160/myapp D/BluetoothAdapter: STATE_ON
09-05 09:08:37.165 8160-8160/myapp D/BluetoothAdapter: STATE_ON
09-05 09:08:37.165 8160-8160/myapp D/BluetoothLeScanner: Start Scan
09-05 09:08:37.165 8160-8160/myapp D/BluetoothAdapter: STATE_ON
09-05 09:08:37.165 8160-8160/myapp D/BluetoothAdapter: STATE_ON
09-05 09:08:37.170 8160-8160/myapp D/BluetoothAdapter: STATE_ON
09-05 09:08:37.170 8160-8160/myapp D/BluetoothAdapter: STATE_ON
09-05 09:08:37.210 8160-12850/myapp D/BluetoothLeScanner: onClientRegistered() - status=133 clientIf=0
09-05 09:08:37.210 8160-12850/myapp D/BluetoothLeScanner: Registration failed, unregister clientIf = 0
09-05 09:08:37.215 8160-8160/myapp D/BluetoothLeScanner: Scan failed, reason app registration failed for UUID = 4c321920-a2b7-449a-bc24-ea4361f7a255
09-05 09:08:44.150 8160-8160/myapp V/myapp.debug: unsubscribing scan
09-05 09:08:44.150 8160-8160/myapp V/myapp.debug: Clearing scan subscription
09-05 09:08:44.150 8160-8160/myapp D/BluetoothAdapter: stopLeScan()
09-05 09:08:44.150 8160-8160/myapp D/BluetoothAdapter: STATE_ON
09-05 09:08:44.155 8160-8160/myapp D/BluetoothAdapter: STATE_ON
09-05 09:08:44.155 8160-8160/myapp D/BluetoothAdapter: STATE_ON
09-05 09:08:44.155 8160-8160/myapp D/BluetoothAdapter: STATE_ON
09-05 09:08:44.155 8160-8160/myapp D/BluetoothLeScanner: could not find callback wrapper
Does anyone have any idea of what causes this problem or what can be done to fix it?
android bluetooth bluetooth-lowenergy android-bluetooth rxandroidble
Hello, I think that during so long time there can appear some errors during the connections you establish with the devices. There is a bug in RxAndroidBle ( github.com/Polidea/RxAndroidBle/issues/63 ) that prevents the BLE clients to be closed properly in some erroneous scenarios.
– Dariusz Seweryn
Sep 8 '16 at 11:35
1
After more investigation I think it's mostly related to the scanning. If I don't scan at all, I don't this problem it appears. I am still interested in learning how to work around the problem if scanning is required for the use case however.
– starman
Sep 14 '16 at 6:52
add a comment |
I am developing an application using the RxAndroidBle
library that performs BLE scans regularly about every 30 seconds, and some BLE operations every minute or so. After a couple of hours, usually between 5 and 24h, the scan stops working. Every time a scan is supposed to be started, I get:
09-05 09:08:37.160 8160-8160/myapp D/BluetoothAdapter: startLeScan(): null
09-05 09:08:37.165 8160-8160/myapp D/BluetoothAdapter: STATE_ON
09-05 09:08:37.165 8160-8160/myapp D/BluetoothAdapter: STATE_ON
09-05 09:08:37.165 8160-8160/myapp D/BluetoothLeScanner: Start Scan
09-05 09:08:37.165 8160-8160/myapp D/BluetoothAdapter: STATE_ON
09-05 09:08:37.165 8160-8160/myapp D/BluetoothAdapter: STATE_ON
09-05 09:08:37.170 8160-8160/myapp D/BluetoothAdapter: STATE_ON
09-05 09:08:37.170 8160-8160/myapp D/BluetoothAdapter: STATE_ON
09-05 09:08:37.210 8160-12850/myapp D/BluetoothLeScanner: onClientRegistered() - status=133 clientIf=0
09-05 09:08:37.210 8160-12850/myapp D/BluetoothLeScanner: Registration failed, unregister clientIf = 0
09-05 09:08:37.215 8160-8160/myapp D/BluetoothLeScanner: Scan failed, reason app registration failed for UUID = 4c321920-a2b7-449a-bc24-ea4361f7a255
09-05 09:08:44.150 8160-8160/myapp V/myapp.debug: unsubscribing scan
09-05 09:08:44.150 8160-8160/myapp V/myapp.debug: Clearing scan subscription
09-05 09:08:44.150 8160-8160/myapp D/BluetoothAdapter: stopLeScan()
09-05 09:08:44.150 8160-8160/myapp D/BluetoothAdapter: STATE_ON
09-05 09:08:44.155 8160-8160/myapp D/BluetoothAdapter: STATE_ON
09-05 09:08:44.155 8160-8160/myapp D/BluetoothAdapter: STATE_ON
09-05 09:08:44.155 8160-8160/myapp D/BluetoothAdapter: STATE_ON
09-05 09:08:44.155 8160-8160/myapp D/BluetoothLeScanner: could not find callback wrapper
Does anyone have any idea of what causes this problem or what can be done to fix it?
android bluetooth bluetooth-lowenergy android-bluetooth rxandroidble
I am developing an application using the RxAndroidBle
library that performs BLE scans regularly about every 30 seconds, and some BLE operations every minute or so. After a couple of hours, usually between 5 and 24h, the scan stops working. Every time a scan is supposed to be started, I get:
09-05 09:08:37.160 8160-8160/myapp D/BluetoothAdapter: startLeScan(): null
09-05 09:08:37.165 8160-8160/myapp D/BluetoothAdapter: STATE_ON
09-05 09:08:37.165 8160-8160/myapp D/BluetoothAdapter: STATE_ON
09-05 09:08:37.165 8160-8160/myapp D/BluetoothLeScanner: Start Scan
09-05 09:08:37.165 8160-8160/myapp D/BluetoothAdapter: STATE_ON
09-05 09:08:37.165 8160-8160/myapp D/BluetoothAdapter: STATE_ON
09-05 09:08:37.170 8160-8160/myapp D/BluetoothAdapter: STATE_ON
09-05 09:08:37.170 8160-8160/myapp D/BluetoothAdapter: STATE_ON
09-05 09:08:37.210 8160-12850/myapp D/BluetoothLeScanner: onClientRegistered() - status=133 clientIf=0
09-05 09:08:37.210 8160-12850/myapp D/BluetoothLeScanner: Registration failed, unregister clientIf = 0
09-05 09:08:37.215 8160-8160/myapp D/BluetoothLeScanner: Scan failed, reason app registration failed for UUID = 4c321920-a2b7-449a-bc24-ea4361f7a255
09-05 09:08:44.150 8160-8160/myapp V/myapp.debug: unsubscribing scan
09-05 09:08:44.150 8160-8160/myapp V/myapp.debug: Clearing scan subscription
09-05 09:08:44.150 8160-8160/myapp D/BluetoothAdapter: stopLeScan()
09-05 09:08:44.150 8160-8160/myapp D/BluetoothAdapter: STATE_ON
09-05 09:08:44.155 8160-8160/myapp D/BluetoothAdapter: STATE_ON
09-05 09:08:44.155 8160-8160/myapp D/BluetoothAdapter: STATE_ON
09-05 09:08:44.155 8160-8160/myapp D/BluetoothAdapter: STATE_ON
09-05 09:08:44.155 8160-8160/myapp D/BluetoothLeScanner: could not find callback wrapper
Does anyone have any idea of what causes this problem or what can be done to fix it?
android bluetooth bluetooth-lowenergy android-bluetooth rxandroidble
android bluetooth bluetooth-lowenergy android-bluetooth rxandroidble
edited Sep 5 '16 at 8:29
Reaz Murshed
12.5k84461
12.5k84461
asked Sep 5 '16 at 7:42
starmanstarman
8219
8219
Hello, I think that during so long time there can appear some errors during the connections you establish with the devices. There is a bug in RxAndroidBle ( github.com/Polidea/RxAndroidBle/issues/63 ) that prevents the BLE clients to be closed properly in some erroneous scenarios.
– Dariusz Seweryn
Sep 8 '16 at 11:35
1
After more investigation I think it's mostly related to the scanning. If I don't scan at all, I don't this problem it appears. I am still interested in learning how to work around the problem if scanning is required for the use case however.
– starman
Sep 14 '16 at 6:52
add a comment |
Hello, I think that during so long time there can appear some errors during the connections you establish with the devices. There is a bug in RxAndroidBle ( github.com/Polidea/RxAndroidBle/issues/63 ) that prevents the BLE clients to be closed properly in some erroneous scenarios.
– Dariusz Seweryn
Sep 8 '16 at 11:35
1
After more investigation I think it's mostly related to the scanning. If I don't scan at all, I don't this problem it appears. I am still interested in learning how to work around the problem if scanning is required for the use case however.
– starman
Sep 14 '16 at 6:52
Hello, I think that during so long time there can appear some errors during the connections you establish with the devices. There is a bug in RxAndroidBle ( github.com/Polidea/RxAndroidBle/issues/63 ) that prevents the BLE clients to be closed properly in some erroneous scenarios.
– Dariusz Seweryn
Sep 8 '16 at 11:35
Hello, I think that during so long time there can appear some errors during the connections you establish with the devices. There is a bug in RxAndroidBle ( github.com/Polidea/RxAndroidBle/issues/63 ) that prevents the BLE clients to be closed properly in some erroneous scenarios.
– Dariusz Seweryn
Sep 8 '16 at 11:35
1
1
After more investigation I think it's mostly related to the scanning. If I don't scan at all, I don't this problem it appears. I am still interested in learning how to work around the problem if scanning is required for the use case however.
– starman
Sep 14 '16 at 6:52
After more investigation I think it's mostly related to the scanning. If I don't scan at all, I don't this problem it appears. I am still interested in learning how to work around the problem if scanning is required for the use case however.
– starman
Sep 14 '16 at 6:52
add a comment |
2 Answers
2
active
oldest
votes
The problem is that after couple of connections you reach a maximal number of BluetoothGatt
objects.
After you disconnect every device before you start a new scan call close()
on your BluetoothGatt
object.
add a comment |
On the older implementations of Android there seems to be a race condition between the time a bluetooth adapter is enabled and how quickly you can do a scan. You can trigger this error by either trying to scan with a disabled bluetooth adapter or one that is transitioning (or has open connections and is trying to read). The underlying issue that was causing it in my app was the inability of the bluetooth sub system to get a new bluetooth socket. The answer above (running out of GATT resources) could be part of it. The overall logic in an older Android device to avoid this issue is: 1. Make sure you disable/enable the bluetooth adapter about every 5 scans. This seems to help clear out older cached data. 2. Make sure you don't try to initiate a scan while the bluetooth adapter is not enabled (this is made possible if you are disabling/enabling on a regular basis). 3. Make sure you have a delay between disconnecting from GATT interfaces and doing your next scan. 4. Don't try to read the GATT characteristics of any more than about 3 devices at a time.
Overall, its somewhat unavoidable in an older Android device to completely avoid the problem but you can mitigate it by carefully timing your scan/stop scan/connect/disconnect/ cycle.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f39325864%2fandroid-ble-scan-failed-reason-app-registration-failed-for-uuid%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
The problem is that after couple of connections you reach a maximal number of BluetoothGatt
objects.
After you disconnect every device before you start a new scan call close()
on your BluetoothGatt
object.
add a comment |
The problem is that after couple of connections you reach a maximal number of BluetoothGatt
objects.
After you disconnect every device before you start a new scan call close()
on your BluetoothGatt
object.
add a comment |
The problem is that after couple of connections you reach a maximal number of BluetoothGatt
objects.
After you disconnect every device before you start a new scan call close()
on your BluetoothGatt
object.
The problem is that after couple of connections you reach a maximal number of BluetoothGatt
objects.
After you disconnect every device before you start a new scan call close()
on your BluetoothGatt
object.
answered Aug 31 '17 at 15:21
Alexander TumaninAlexander Tumanin
7721026
7721026
add a comment |
add a comment |
On the older implementations of Android there seems to be a race condition between the time a bluetooth adapter is enabled and how quickly you can do a scan. You can trigger this error by either trying to scan with a disabled bluetooth adapter or one that is transitioning (or has open connections and is trying to read). The underlying issue that was causing it in my app was the inability of the bluetooth sub system to get a new bluetooth socket. The answer above (running out of GATT resources) could be part of it. The overall logic in an older Android device to avoid this issue is: 1. Make sure you disable/enable the bluetooth adapter about every 5 scans. This seems to help clear out older cached data. 2. Make sure you don't try to initiate a scan while the bluetooth adapter is not enabled (this is made possible if you are disabling/enabling on a regular basis). 3. Make sure you have a delay between disconnecting from GATT interfaces and doing your next scan. 4. Don't try to read the GATT characteristics of any more than about 3 devices at a time.
Overall, its somewhat unavoidable in an older Android device to completely avoid the problem but you can mitigate it by carefully timing your scan/stop scan/connect/disconnect/ cycle.
add a comment |
On the older implementations of Android there seems to be a race condition between the time a bluetooth adapter is enabled and how quickly you can do a scan. You can trigger this error by either trying to scan with a disabled bluetooth adapter or one that is transitioning (or has open connections and is trying to read). The underlying issue that was causing it in my app was the inability of the bluetooth sub system to get a new bluetooth socket. The answer above (running out of GATT resources) could be part of it. The overall logic in an older Android device to avoid this issue is: 1. Make sure you disable/enable the bluetooth adapter about every 5 scans. This seems to help clear out older cached data. 2. Make sure you don't try to initiate a scan while the bluetooth adapter is not enabled (this is made possible if you are disabling/enabling on a regular basis). 3. Make sure you have a delay between disconnecting from GATT interfaces and doing your next scan. 4. Don't try to read the GATT characteristics of any more than about 3 devices at a time.
Overall, its somewhat unavoidable in an older Android device to completely avoid the problem but you can mitigate it by carefully timing your scan/stop scan/connect/disconnect/ cycle.
add a comment |
On the older implementations of Android there seems to be a race condition between the time a bluetooth adapter is enabled and how quickly you can do a scan. You can trigger this error by either trying to scan with a disabled bluetooth adapter or one that is transitioning (or has open connections and is trying to read). The underlying issue that was causing it in my app was the inability of the bluetooth sub system to get a new bluetooth socket. The answer above (running out of GATT resources) could be part of it. The overall logic in an older Android device to avoid this issue is: 1. Make sure you disable/enable the bluetooth adapter about every 5 scans. This seems to help clear out older cached data. 2. Make sure you don't try to initiate a scan while the bluetooth adapter is not enabled (this is made possible if you are disabling/enabling on a regular basis). 3. Make sure you have a delay between disconnecting from GATT interfaces and doing your next scan. 4. Don't try to read the GATT characteristics of any more than about 3 devices at a time.
Overall, its somewhat unavoidable in an older Android device to completely avoid the problem but you can mitigate it by carefully timing your scan/stop scan/connect/disconnect/ cycle.
On the older implementations of Android there seems to be a race condition between the time a bluetooth adapter is enabled and how quickly you can do a scan. You can trigger this error by either trying to scan with a disabled bluetooth adapter or one that is transitioning (or has open connections and is trying to read). The underlying issue that was causing it in my app was the inability of the bluetooth sub system to get a new bluetooth socket. The answer above (running out of GATT resources) could be part of it. The overall logic in an older Android device to avoid this issue is: 1. Make sure you disable/enable the bluetooth adapter about every 5 scans. This seems to help clear out older cached data. 2. Make sure you don't try to initiate a scan while the bluetooth adapter is not enabled (this is made possible if you are disabling/enabling on a regular basis). 3. Make sure you have a delay between disconnecting from GATT interfaces and doing your next scan. 4. Don't try to read the GATT characteristics of any more than about 3 devices at a time.
Overall, its somewhat unavoidable in an older Android device to completely avoid the problem but you can mitigate it by carefully timing your scan/stop scan/connect/disconnect/ cycle.
answered Nov 19 '18 at 21:57
David RubieDavid Rubie
1
1
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f39325864%2fandroid-ble-scan-failed-reason-app-registration-failed-for-uuid%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Hello, I think that during so long time there can appear some errors during the connections you establish with the devices. There is a bug in RxAndroidBle ( github.com/Polidea/RxAndroidBle/issues/63 ) that prevents the BLE clients to be closed properly in some erroneous scenarios.
– Dariusz Seweryn
Sep 8 '16 at 11:35
1
After more investigation I think it's mostly related to the scanning. If I don't scan at all, I don't this problem it appears. I am still interested in learning how to work around the problem if scanning is required for the use case however.
– starman
Sep 14 '16 at 6:52