I run a custom multilink BLE service server on nRF9160 DK.
After about 20 minutes of repeated connecting, data exchange and disconnecting from 4 (only four) BLE devices I get this log:
[00:18:43.188,781] <wrn> bt_conn: Disconnected while allocating context
It appears deep inside bt_gatt_notify_cb() call stack when I'm trying to publish data to Notify char
if (bt_gatt_is_subscribed(conn, attr, BT_GATT_CCC_NOTIFY)) { int err = bt_gatt_notify_cb(conn, ¶ms); }
Both before (bt_gatt_is_subscribed()
) and inside the call there are checks for conn->state
to be BT_CONN_CONNECTED
, but when it comes to context allocation is becomes BT_CONN_DISCONNECT_COMPLETE
.
Soon after it looks like this:
[00:22:50.196,044] <wrn> bt_conn: Unable to allocate buffer within timeout [00:22:50.196,044] <err> bt_l2cap: Unable to allocate buffer for op 0x12 [00:23:13.196,655] <wrn> bt_conn: Unable to allocate buffer within timeout [00:23:13.196,655] <err> bt_att: Unable to allocate buffer for op 0x07 [00:23:43.196,746] <wrn> bt_conn: Unable to allocate buffer within timeout [00:23:43.196,746] <err> bt_att: Unable to allocate buffer for op 0x01 [00:23:43.197,662] <inf> : Connected F9:BD:FC:A5:A0:B3 (random) [00:23:43.197,814] <wrn> bt_att: Not connected [00:23:43.197,967] <inf> : Disconnected: reason 19) [00:23:50.197,631] <wrn> bt_conn: Unable to allocate buffer within timeout [00:23:50.197,631] <err> bt_l2cap: Unable to allocate buffer for op 0x12 [00:24:13.197,906] <wrn> bt_conn: Unable to allocate buffer within timeout [00:24:13.197,906] <err> bt_att: Unable to allocate buffer for op 0x01 [00:24:13.198,913] <inf> : Connected E2:3B:8B:13:08:72 (random) [00:24:13.199,523] <inf> : Disconnected: reason 19) [00:24:20.198,883] <wrn> bt_conn: Unable to allocate buffer within timeout [00:24:20.198,883] <err> bt_l2cap: Unable to allocate buffer for op 0x12 [00:24:43.199,462] <wrn> bt_conn: Unable to allocate buffer within timeout [00:24:43.199,462] <err> bt_att: Unable to allocate buffer for op 0x07 [00:25:13.199,554] <wrn> bt_conn: Unable to allocate buffer within timeout [00:25:13.199,554] <err> bt_att: Unable to allocate buffer for op 0x01
How do I handle this error on the server side, or better yet, prevent it? What causes this?