question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't discover service, and then 'org.bluez.Error.Failed' after a minute

See original GitHub issue

I’m using RPi 4 (with node 14.9.0, BlueZ 5.50). I can discover the device, but not the service.

require('dotenv').config()

const { createBluetooth } = require('.')
const { TEST_DEVICE, TEST_SERVICE, TEST_CHARACTERISTIC, TEST_NOTIFY_SERVICE, TEST_NOTIFY_CHARACTERISTIC } = process.env

async function main () {
  const { bluetooth, destroy } = createBluetooth()

  // get bluetooth adapter
  const adapter = await bluetooth.defaultAdapter()
  await adapter.startDiscovery()
  console.log('discovering')

  // get device and connect
  const device = await adapter.waitDevice('D4:CA:6E:F1:84:BE')
  console.log('got device', await device.getAddress(), await device.getName())
  await device.connect()
  console.log('connected')

  const gattServer = await device.gatt()

  // read write characteristic
  const service1 = await gattServer.getPrimaryService('15172000-4947-11e9-8646-d663bd873d93')
  console.log('got primary service.')
  const characteristic1 = await service1.getCharacteristic('15172001-4947-11e9-8646-d663bd873d93')
  console.log('got control characteristic.')
  //await characteristic1.writeValue(Buffer.from('Hello world'))
  const buffer = await characteristic1.readValue()
  console.log('read', buffer, buffer.toString())

}

main()
  .then(console.log)
  .catch(console.error)

Console output

discovering
got device D4:CA:6E:F1:84:BE Xsens DOT
DBusError: Software caused connection abort
    at _methodReturnHandlers.<computed> (/home/pi/node-ble-master/node_modules/dbus-next/lib/bus.js:339:27)
    at handleMessage (/home/pi/node-ble-master/node_modules/dbus-next/lib/bus.js:98:11)
    at EventEmitter.<anonymous> (/home/pi/node-ble-master/node_modules/dbus-next/lib/bus.js:147:9)
    at EventEmitter.emit (events.js:314:20)
    at /home/pi/node-ble-master/node_modules/dbus-next/lib/connection.js:112:14
    at Socket.<anonymous> (/home/pi/node-ble-master/node_modules/dbus-next/lib/message.js:63:9)
    at Socket.emit (events.js:314:20)
    at emitReadable_ (_stream_readable.js:563:12)
    at processTicksAndRejections (internal/process/task_queues.js:79:21) {
  type: 'org.bluez.Error.Failed',
  text: 'Software caused connection abort',
  reply: Message {
    type: 3,
    _sent: false,
    _serial: 1494,
    path: undefined,
    interface: undefined,
    member: undefined,
    errorName: 'org.bluez.Error.Failed',
    replySerial: 13,
    destination: ':1.68',
    sender: ':1.22',
    signature: 's',
    body: [ 'Software caused connection abort' ],
    flags: 1
  }
}


Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
mohse-ncommented, Dec 2, 2020

I was using Raspberry Pi 3 and 4. Upgrading to the latest version of Raspbian (Raspberry Pi OS) solved the problem for me.

0reactions
dave190265commented, Apr 10, 2021

In order to debug the issue, I suggest you the following lines:

$  bluetoothctl
> connect DC:A6:32:3F:7B:7A
> menu gatt
> list-attributes

Does bluetoothctl list the expected services?

I get the same problem. I’m running in a Docker Image on a RPi4.

I can ssh into the docker image and when I try https://github.com/chrvadala/node-ble/issues/13#issuecomment-761858089 I get the following :

[bluetooth]#
[CHG] Device 7B:41:00:00:04:98 ManufacturerData Value: 0x00
[bluetooth]#
[CHG] Device 7B:41:00:00:04:98 ManufacturerData Value: 0x00
[bluetooth]# connect 7B:41:00:00:04:98
Attempting to connect to 7B:41:00:00:04:98
[bluetooth]#
Failed to connect: org.bluez.Error.Failed
[bluetooth]#

In my code, I can get the device, and getAddress and getName work as expected, but when I attempt to connect, I get :

*** BLE devices: [ ‘7B:41:00:00:04:98’, ‘DC:0D:30:01:14:C3’ ] got device 7B:41:00:00:04:98 ThermoBeacon false (node:32) UnhandledPromiseRejectionWarning: DBusError: Software caused connection abort at methodReturnHandlers.(anonymous function) (/srv/node_modules/dbus-next/lib/bus.js:343:27) at handleMessage (/srv/node_modules/dbus-next/lib/bus.js:101:11) at EventEmitter.MessageBus.conn.on (/srv/node_modules/dbus-next/lib/bus.js:151:9) at EventEmitter.emit (events.js:198:13) at /srv/node_modules/dbus-next/lib/connection.js:116:14 at Socket.<anonymous> (/srv/node_modules/dbus-next/lib/message.js:63:9) at Socket.emit (events.js:198:13) [Logs] [4/10/2021, 1:23:47 PM] [smart-hub] at emitReadable (_stream_readable.js:555:12) [Logs] [4/10/2021, 1:23:47 PM] [smart-hub] at process._tickCallback (internal/process/next_tick.js:63:19)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error when trying to connect to bluetooth speaker: `org.bluez ...
This may be due to the pulseaudio-module-bluetooth package not being installed. Install it if it missing, then restart pulseaudio.
Read more >
org.bluez.Error.Failed br-connection-unknown - Ask Ubuntu
Today after booting up the computer I was able to pair the speaker, I have no idea why. However I am now getting...
Read more >
Failed to connect: org.bluez.Error.Failed - Raspberry Pi Forums
I have a vanilla Raspberry OS installation. My HDMI monitor has no audio. I tried to connect JBL Flip 4 - error (please...
Read more >
[SOLVED] Bluetooth connect failed: br-connection-profile ...
Failed to connect: org.bluez.Error.Failed br-connection-profile- ... after doing a full reboot and then in bluetoothctl a trust <dev>; ...
Read more >
Bluetooth refuses to work properly - Bug reports - EndeavourOS
When trying to connect the buds+ it is even worse, since the whole bluetooth service hangs up and I need to reboot the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found