NordicSemiconductor / Android-BLE-Library

A library that makes working with Bluetooth LE on Android a pleasure. Seriously.
BSD 3-Clause "New" or "Revised" License
2.03k stars 417 forks source link

Server closes all connections with error 0x101 #511

Open DmytroBatyuk opened 1 year ago

DmytroBatyuk commented 1 year ago

I'm using no.nordicsemi.android:ble-ktx:2.6.1 library for the server app. Server app is running 24/7 on device with Android 9. Server app does BLE advertising 24/7 and accept connections beside.

After few days of app work I figured out that another devices stopped connecting to the server device and I added more logs to my analytic and found out that device instantly rejects the BLE connection with other devices and I see the log print at line which says Error: (0x101): UNKNOWN (257).

I do not turn off the device, device never goes to idle mode and keeps app opened. There are no BT adapter restarts.

Client side also uses nordic library to connect to the server on Android and native BLE stack provided by the system on iOS.

This issue occurs on more devices every day. We are using the same device model running Android 7 on for all of them.

Device restart doesn't solve the problem.

When BLE communication did work log at line was reporting one of Error: (0x13): GATT CONN TERMINATE PEER USER; Error: (0x8): GATT CONN TIMEOUT; Error: (0x28): UNKNOWN (40).

I did search in the nordic library and found out this TOO_MANY_OPEN_CONNECTIONS error, not sure should I focus on this error or not.

Did I do something wrong?

Thanks beforehand, Dima

philips77 commented 1 year ago

Are you reusing the same BleManager instance for the connections on server side, or creating a new one each time a connection is received?