question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

IOS strange and random disconnects (Code=6 "The connection has timed out unexpectedly.")

See original GitHub issue

I’m not sure, that is a bug in this library, but I would like to find any information or opinion, that can help!

Prerequisites

I connect a peripheral device to a phone (ios/android) and then get a large amount of data from the device using notifications. (Stream this data by subscribing on one of the characteristics - device.monitorCharacteristicForService). As the device, I use an emulator on “bleno” library.

  • [+] I am running the latest version
  • [+] I checked the documentation and found no answer
  • [+/-] I checked to make sure that this issue has not already been filed

Expected Behavior

I need no automatic and unexpected disconnects on IOS if the connection is good (signal and so on). As currently in android - everything is fine.

Current Behavior

Stably disconnections on IOS in 1-2 minutes after connection. Connection time until disconnect is random but as rule max is 2 minutes. On android everything is okay and the connection is not interrupted and there are not any disconnects.

By the way, I saw similar behavior with my Mi Band 4 and the official app on IOS. On Android, everything is okay too.

Steps to Reproduce

There are two situations:

  1. Just connect a peripheral device to the IOS device (bleManager.connectToDevice, bleManager.discoverAllServicesAndCharacteristicsForDevice) and wait. In 1-2 minutes device will be disconnected automatically (device.onDisconnected listener get device object and error = null) with next logs:
[RxBLEKit|DEBG|07:55:53.167]: CentralManager(10804420368) didDisconnect(from: Peripheral(uuid: A3F1E5A5-8D4B-C689-F87E-D706FB898478, name: Optional("my-mac")),
error: Optional(Error Domain=CBErrorDomain Code=6 "The connection has timed out unexpectedly." UserInfo={NSLocalizedDescription=The connection has timed out unexpectedly.}))
  1. Connect to a device, subscribe to notifications and start streaming data from device to phone. Then in 1-2 will be a disconnect. For example, here I managed to get 712 notifications and then there is an unexpected disconnect (device.onDisconnected listener get device object and error = null):
[RxBLEKit|DEBG|08:07:37.102]: Peripheral(uuid: A3F1E5A5-8D4B-C689-F87E-D706FB898478, name: Optional(“my-mac")) didUpdateValueFor(for:Characteristic(uuid: 6CA841C2-CE94-443C-BF2E-5F0790402164, id: 10739225088),
value: Optional("fc8481fc7ff6fc7ec2fc7f37fc8004fc84c9"),
error: nil)
[RxBLEKit|DEBG|08:07:37.103]: Peripheral(uuid: A3F1E5A5-8D4B-C689-F87E-D706FB898478, name: Optional("my-mac")) didUpdateValueFor(for:Characteristic(uuid: 6CA841C2-CE94-443C-BF2E-5F0790402164, id: 10739225088),
value: Optional("fc88effc8e2dfc8b5efc83dbfc80f9fc7c93"),
error: nil)
[RxBLEKit|DEBG|08:07:37.825]: CentralManager(10752780240) didDisconnect(from: Peripheral(uuid: A3F1E5A5-8D4B-C689-F87E-D706FB898478, name: Optional("my-mac")),
error: Optional(Error Domain=CBErrorDomain Code=6 "The connection has timed out unexpectedly." UserInfo={NSLocalizedDescription=The connection has timed out unexpectedly.}))
Unhandled error happened: Connection error has occured: -
 subscription called from:

Sometimes I can get 2500 notifications without disconnects, but it’s a really rare situation…

Context

I tried finding something on the internet by this error code and message and found next:

  1. https://stackoverflow.com/questions/32588325/ios-bluetooth-le-code-6-the-connection-has-timed-out-unexpectedly
  2. https://devzone.nordicsemi.com/f/nordic-q-a/9224/ios-8-disconnection-code-6-the-connection-has-timed-out-unexpectedly
  3. https://github.com/innoveit/react-native-ble-manager/issues/555

Looks like it’s some problem or feature of apple devices, but I believe that there is a solution because it’s really strange. I’m not so good at the BLE topic and probably missed some important detail and as a result, have this situation with disconnects on IOS.

But I believe that there is someone who knows what to do or had this situation too! And wait for your help or opinion 😃

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
rhakhcommented, Nov 29, 2021

@ekrivenja-sequenex Yes. BLE and Wi-Fi (2.4 ghz) works on the same frequency. Try to find “clear” space and try again to connect devices.

0reactions
ekrivenja-sequenexcommented, Nov 29, 2021

@rhakh , do you mean everything is about 2.4GHz interference?

Read more comments on GitHub >

github_iconTop Results From Across the Web

IOS strange and random disconnects (Code=6 "The ... - GitHub
Stably disconnections on IOS in 1-2 minutes after connection. Connection time until disconnect is random but as rule max is 2 minutes.
Read more >
Peripheral Randomly Disconnects: with Code=6
Hello,. I am working on an application where there is an option of "Change Peripheral Device", which discoonects with the respective peripheral and...
Read more >
iOS Bluetooth LE: Code=6 "The connection has timed out ...
The error is: Code=6 "The connection has timed out unexpectedly." The time between connection and this disconnection is random. I've measured ...
Read more >
iOS 8 disconnection: Code=6 "The connection has timed out ...
It will spontaneously disconnect some time after connection. The time between connection and this disconnection is random. I've measured from ...
Read more >
5 Reasons Why Your Internet Keeps Disconnecting—and ...
Your randomly disconnecting internet could indeed be caused by outages from your ISP. The easiest way to find out is simply calling your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found