Skip to content

Process hangs on client disconnect #11

@wwaaijer

Description

@wwaaijer

Coming from v0.6, I was exited to upgrade Bleno to use the multiple connections support.
But I ran into an issue.

Reduced to a simple Bleno peripheral setup with a battery level service (read-only).
Client connects, reads the battery level, and disconnects after 3 seconds.
Everything works fine, until disconnecting.

When the client disconnects, the Node.js process just hangs and never emits the disconnect event.

Traced the issue with some logging throughout the disconnection process:

  • Internally the disconnComplete event is emitted by the (main) hci-socket
  • Bleno starts closing the internal aclStream belonging to the specific handle
  • Which calls stop() on the hci socket (owned by the Mgmt class)
  • This gets to BluetoothHciSocketWrapped.stop() in @stoprocent/bluetooth-hci-socket/lib/native.js
  • From there, the Node.js process just hangs

Currently I lack the tools or expertise to debug the C++ code.
However, i would guess in BluetoothHciSocket.cpp that the pollingThread.join() is never returning for some reason?
Is the read call blocking, waiting for the socket to be closed, first?

Seems to have been working until just before v0.9.0, when the multiple connections support was added.
Running on a Raspberry Pi 3 B+ with Linux raspberrypi 6.1.21-v8, updated everything, Node.js v24.

P.S. already had great fun with your version of Bleno, thanks for your work on it!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions