BLE Error when calling disconnect inside callback for connected

Hi,

I am developing a peripheral in ble, and I receive the following error when I disconnect a new connection within the connection callback.

bt_conn_disconnect(conn, BT_HCI_ERR_REMOTE_USER_TERM_CONN);

[00:00:07.533,966] <wrn> bt_att: att_get: Not connected
[00:00:07.631,561] <err> bt_conn: bt_conn_send_cb: not connected!

I have also seen this error when I repeatedly connect to the peripheral:

[02:11:23.832,550] <err> bt_conn: bt_conn_send_cb: not connected!

The connected callback simply looks at the connection info (bt_conn_get_info) and then disconnects(bt_conn_disconnect).

The errors are inconsistent.  They don't always happen, and they're not always the same.

Often I see the bt_att issue on the first connection, but not always.

I am repeatedly connecting to the peripheral at a fast rate using the nRF Connect phone app.

Interestingly, when the peripheral disconnects the phone as described, the phone sometimes gets stuck in a re-connection loop.  This is how the subscriptions are coming in so quickly in some cases.

To be clear though, I do frequently see the very simple case described above on the first connection and no looping.

Notably, the return value from the bt_conn_disconnect is 0 (success) on those errors.

Question - what is the right way to use the API to avoid these errors?  I want to be able to disconnect new connections within the connected callback.

Thanks.