Alex MitrovicBLE & IoT app developer, Android and iOS

Connections

Android BLE connection drops: what status 8, 19 and 22 mean and how to fix them

Why Android BLE connections drop: what disconnect statuses 8, 19, 22 and 0x3D mean, how to tell them apart, and a reconnect policy that works.

Short answer

When an Android BLE connection drops, the status in onConnectionStateChange says who ended it: 8 means the link timed out (range, interference or a device reset), 19 means the device disconnected on purpose, and 22 means the phone's own Bluetooth stack ended it, often after a pairing or encryption problem. Close the old BluetoothGatt, then reconnect according to the status instead of with one retry loop for everything.

Key takeaways

  • The disconnect status is a reason code: it tells you which side ended the link, not why.
  • Status 8 is a supervision timeout. Check range, RSSI before the drop, and whether the device reset.
  • Status 19 sends you to the firmware: idle timeouts, single-connection limits, reboots after OTA.
  • Status 22 and 0x3D usually point at pairing and encryption, often a stale bond.
  • Reconnect per status, with backoff, and log the status, the time connected and the phone model every time.

A connection that works for a while and then drops is the most common BLE bug report I get. Users call it “disconnects randomly”. It's rarely random. Android tells you who ended the link in the status of onConnectionStateChange, and with a few more facts logged around it, most drops fall into one of four groups.

What do the Android disconnect statuses mean?

When a connection ends, Android calls onConnectionStateChange(gatt, status, STATE_DISCONNECTED). For a disconnect, the status is mostly the HCI reason code from the Bluetooth controller, passed through as a number:

StatusNameWho ended itUsual causes
0GATT_SUCCESSYour appYou called disconnect(), or something in your code did
8GATT_CONN_TIMEOUTNobody: the link was lostOut of range, body or wall in the way, interference, device reset or brown-out, supervision timeout too short
19GATT_CONN_TERMINATE_PEER_USERThe deviceFirmware idle timeout, only one connection allowed, reboot after an update, the device rejecting what the app did
22GATT_CONN_TERMINATE_LOCAL_HOSTThe phone's stackPairing or encryption failure, stale bond, the stack closing a link no client is using
34GATT_CONN_LMP_TIMEOUTNobody: a procedure hungDevice didn't answer a link-layer procedure (parameter update, PHY update, encryption)
61 (0x3D)MIC failureThe controllerEncrypted packets failed their check: keys don't match, almost always a stale bond
133GATT_ERRORUnclearAs a disconnect, often right after connecting; see GATT 133

Type any code into the lookup below if yours isn't in the table.

Tool

GATT status code lookup

27 codes

DecHexNameMeaningCheck first
00x00GATT_SUCCESS
any
Success. With STATE_DISCONNECTED it usually means your app asked for the disconnect.Nothing, unless you didn't call disconnect(): then look for code that does.
10x01GATT_INVALID_HANDLE
operation
The attribute handle doesn't exist on the device.Stale GATT cache after a firmware update: rediscover services, or have the device send Service Changed.
20x02GATT_READ_NOT_PERMITTED
operation
The characteristic can't be read.Check its properties in the GATT table; you may need notifications instead.
30x03GATT_WRITE_NOT_PERMITTED
operation
The characteristic can't be written, or not with this write type.Compare WRITE vs WRITE_NO_RESPONSE in the characteristic's properties.
50x05GATT_INSUFFICIENT_AUTHENTICATION
operation
The device wants an authenticated (paired) link for this attribute.Bond first, or let Android start pairing; wait for BOND_BONDED before retrying.
60x06GATT_REQUEST_NOT_SUPPORTED
operation
The device doesn't support this request.Check the firmware handles the operation (e.g. long writes, reliable writes).
70x07GATT_INVALID_OFFSET
operation
A read or prepared write used an offset past the end of the value.Long reads/writes and their offsets; usually a protocol or firmware bug.
80x08GATT_CONN_TIMEOUT
connection
The link was lost: no packets within the supervision timeout. Out of range, device reset, interference. (In an operation callback, 8 is GATT_INSUFFICIENT_AUTHORIZATION.)Range and RSSI before the drop, device resets, supervision timeout vs connection interval. Reconnect with autoConnect = true.
130x0DGATT_INVALID_ATTRIBUTE_LENGTH
operation
The value written is longer than the attribute allows.Payload size vs MTU − 3, and the firmware's max length for that characteristic.
150x0FGATT_INSUFFICIENT_ENCRYPTION
operation
The attribute needs an encrypted link.Bonding and encryption; a stale bond often shows up here.
190x13GATT_CONN_TERMINATE_PEER_USER
connection
The device ended the connection on purpose.Firmware: idle timeouts, a reboot after OTA, a single-connection limit, or rejecting your app's behavior.
220x16GATT_CONN_TERMINATE_LOCAL_HOST
connection
The phone's Bluetooth stack ended the link.Pairing or encryption failures, a stale bond, or the stack closing a link no client is using.
340x22GATT_CONN_LMP_TIMEOUT
connection
The device stopped answering a link-layer procedure (LL response timeout).Firmware handling of connection-parameter updates, PHY updates or encryption; check with an HCI log.
590x3BUNACCEPTABLE_CONN_PARAMS
connection
The connection parameters were rejected.Connection interval, latency and supervision timeout requested by the device or the app.
610x3DCONN_TERMINATED_MIC_FAILURE
connection
Encrypted packets failed their integrity check, so the link was dropped.Almost always a key mismatch: a stale bond after the device was reset. Remove the bond and pair again.
620x3EGATT_CONN_FAIL_ESTABLISH
connection
The connection failed to be established: the device never answered.Is it advertising and connectable? Range, a busy device, or another phone already connected.
1280x80GATT_NO_RESOURCES
any
The stack ran out of resources.Leaked BluetoothGatt clients or too many connections; close what you don't use.
1290x81GATT_INTERNAL_ERROR
any
An internal error in the Bluetooth stack.Usually a timing or state problem; serialize operations and retry once.
1300x82GATT_WRONG_STATE
any
The operation isn't valid in the current state.An operation sent before discovery finished, or after a disconnect.
1320x84GATT_BUSY
any
Another operation is still running.You need a GATT operation queue: one operation at a time, wait for each callback.
1330x85GATT_ERROR
connection
Android's generic failure: the connection didn't happen and no more specific code applied.Time it: under a second points at leaked clients or the stack; ~30 s points at the device. Close every failed BluetoothGatt.
1350x87GATT_ILLEGAL_PARAMETER
operation
A parameter in the request was invalid.Values, lengths and write types passed to the API.
1370x89GATT_AUTH_FAIL
any
Authentication failed during pairing.Wrong passkey, the user cancelled, or the device and phone disagree on security level.
1430x8FGATT_CONNECTION_CONGESTED
operation
The link is congested; slow down.Wait for onCharacteristicWrite before the next write without response.
1470x93GATT_CONNECTION_TIMEOUT
connection
A connection attempt ran out of time (newer stacks).Treat like 133 after ~30 s: is the device advertising and in range?
201201ERROR_GATT_WRITE_REQUEST_BUSY
API 33+
BluetoothStatusCodes: a write was rejected because another request is in flight.Queue your operations; never write before the previous callback arrived.
2570x101GATT_FAILURE
any
A generic failure.Log the operation and state around it; often a firmware rejection or stack problem.

What to log on every disconnect

A status alone isn't enough to fix anything. Log these with it, every time, and you'll be able to sort field reports in minutes:

  • The status and the time since the connection was established. A drop after 2 seconds and a drop after 40 minutes are different bugs.
  • The last RSSI you read (readRemoteRssi() every few seconds is cheap). A drop at -95 dBm is range; at -50 dBm it isn't.
  • The last GATT operation before the drop, and whether it completed.
  • Phone manufacturer, model, Android version, and whether the screen was on.
  • The device's firmware version and, if the firmware can tell you, its reset reason on the next connect.

Status 8: the link timed out

Status 8 means no packet got through within the supervision timeout, a value agreed when the connection was set up (often a few seconds). Both sides give up and report the link as lost. That's what happens when the user walks away, puts the phone in a back pocket next to the device's antenna, or the device resets.

How to tell the causes apart:

  • Weak RSSI before the drop: range. Nothing to fix in code except reconnecting gracefully, and maybe the device's TX power or antenna.
  • Good RSSI, drop at a random time: the device may have reset. Ask the firmware team for a reset-reason register and read it after reconnecting.
  • Drops right after a connection parameter change: the supervision timeout may be too short for the interval and latency. The spec requires it to be longer than (1 + peripheral latency) × connection interval × 2, and in practice it needs a good margin above that.
  • Drops only with the screen off on some brands: check the phone's battery optimization first. Some vendors are aggressive with Bluetooth when the app isn't in a foreground service.

The fix on the app side: close the old BluetoothGatt and reconnect with autoConnect = true, which waits for the device without a timeout and connects when it's back.

Status 19: the device ended it

19 means the peripheral sent a disconnect on purpose. The app can't stop that, but it can usually find out why. The most common reasons:

  • An idle timeout in the firmware. If drops happen at a suspiciously round time after the last activity (30 s, 60 s), that's it. Either keep the link busy on purpose or agree a longer timeout with the firmware team.
  • The device only accepts one connection and another phone, or another app on the same phone, took it.
  • A reboot after a firmware update or a configuration write. Expected, so the app should know to wait and reconnect, not show an error.
  • The firmware rejecting something: a write it considers invalid, a missing authentication step, or a protocol version it doesn't support.

Add one real case: which device, what the drop pattern looked like and what the cause turned out to be (no client names).

Status 22 and 0x3D: usually pairing and keys

22 means the phone's stack ended the connection itself. In my experience the most common trigger is security: the device asked for encryption, pairing failed or keys didn't match, and Android dropped the link. Status 61 (0x3D, “MIC failure”) is more specific: encrypted packets failed their integrity check, which means the two sides have different keys. That's the classic stale bond after a device was reset or reflashed while the phone kept its old pairing.

Android can also tear down a link that no app is using anymore, a short while after the last BluetoothGatt on it was closed. If you see 22 shortly after your own code closed a client, check that you didn't close the one you still needed.

For stale bonds, decide with the firmware team how a reset device re-pairs, and detect the case in the app so you can tell users what to do. More in Android BLE bonding problems.

A reconnect policy that follows the status

One retry loop for every disconnect is how apps end up hammering a device that is rebooting, or never reconnecting after a timeout. Map the status to a decision instead:

A disconnect policy per status
sealed interface Reconnect {
    data object Background : Reconnect                    // autoConnect = true, no timeout
    data class After(val delayMs: Long) : Reconnect       // direct connect after a pause
    data class Stop(val reason: String) : Reconnect       // tell the user, don't retry
}

fun policyFor(status: Int, userRequested: Boolean, attempt: Int): Reconnect = when {
    userRequested -> Reconnect.Stop("user disconnected")
    status == 8 -> Reconnect.Background                              // lost link: wait for it
    status == 19 -> Reconnect.After(backoff(attempt, base = 2_000))  // device ended it, maybe rebooting
    status == 22 || status == 61 ->
        if (attempt < 1) Reconnect.After(1_000) else Reconnect.Stop("pairing problem")
    status == 133 || status == 62 -> Reconnect.After(backoff(attempt, base = 600))
    else -> Reconnect.After(backoff(attempt, base = 1_000))
}

private fun backoff(attempt: Int, base: Long) =
    (base shl attempt.coerceAtMost(5)).coerceAtMost(30_000)

Around it, the rules from GATT 133 still apply: close() the old BluetoothGatt on every disconnect, never reuse it, and keep one connection attempt in flight at a time. If you need the link to survive the screen turning off, run it from a foreground service; see background BLE on Android.

Add a result you can share, e.g. "field disconnects per user-day down X% after per-status reconnects and longer supervision timeout".

FAQ

What does status 8 mean in Android BLE?

Status 8 is GATT_CONN_TIMEOUT: no packet got through within the connection's supervision timeout, so the link was considered lost. The usual causes are range, obstacles, interference or the device resetting. Reconnect with autoConnect = true.

Why does my BLE device disconnect after exactly 30 or 60 seconds?

A drop at a round number of seconds after the last activity is almost always an idle timeout in the device's firmware, reported on Android as status 19. Agree a longer timeout with the firmware team or keep the link active.

What is the difference between disconnect() and close() on Android?

disconnect() ends the connection but keeps the BluetoothGatt client registered; close() releases it. After a disconnect you don't plan to resume on the same object, call close(), or the phone eventually runs out of clients and connections fail with 133.

Should I reconnect automatically after every BLE disconnect?

No. Reconnect according to the status: wait in the background after a timeout (8), pause and retry after the device ended it (19), and stop and tell the user after repeated pairing failures (22, 0x3D). Never reconnect after the user disconnected.

Sources

Seeing this in your own app?

Send me the phone models and what the logs say. On a short call I'll tell you where I'd look first.

Book a free call

Free · NDA on request · reply within 1–2 working days