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.

connectToDevice doesn't time out on iOS

See original GitHub issue

This may be an issue or just a question.

We have a situation where we have to poll a device characteristic for some data. Multiple clients may be in range and do the same polling, which could mean one phone is currently connected while another one also tries to connect. The target may also be turned off so that it’s not available at all.

On Android, connecting while it’s busy or turned off fails with an error after about 5 seconds. On iOS it can wait for several minutes then finally resolve as soon as the target is available again. Log example:

11:06:52 Reading...
11:06:52 Successfully read!
11:07:00 Reading...
11:09:54 Successfully read! <-- Note the timestamp

I also tried waiting for about 10 minutes; the connection seemed to actually hang there and any subsequent connection attempts resulted in an error, I’m guessing because a connection was already underway.

Android log example, what’s expected:

11:24:19 Reading...
11:24:20 Successfully read!
11:24:25 Reading...
11:24:30 Unknown error: BleDisconnectedException{bluetoothDeviceAddress='ABC'}
11:24:35 Reading...
11:24:41 Unknown error: BleDisconnectedException{bluetoothDeviceAddress='ABC'}
11:24:46 Reading...
11:24:51 Unknown error: BleDisconnectedException{bluetoothDeviceAddress='ABC'}
11:24:56 Reading...
11:24:57 Successfully read!

Is this a known iOS behavior?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
dariuszseweryncommented, Oct 30, 2017

autoConnect=true does two things:

  1. Removes the 30 seconds timeout
  2. Makes the Android OS to use more relaxed setting of the scan—this makes the time needed for connection to be established longer (sometimes much longer) than in direct mode (autoConnect=false). I have seen situations that it took more than 5-10 minutes even if devices had been right beside each other.

As for the background behaviour I encourage you to read the documentation or check some other articles as this is a complex topic and it is hard to condensate everything into a single post.

1reaction
jl-mindiuscommented, Oct 30, 2017

@dariuszseweryn Yeah I guess the behavior can differ between vendors like Cierpliwy said (we’re using a mid-range Samsung for testing). So iOS seems to be in something like auto connect mode by default? Would setting autoConnect=true for Android affect anything more than the timeout, like automatic reconnect after disconnect or things like that? We only want to do a quick connect-read-disconnect.

Could you elaborate a bit on background behavior? It’s something we will explore for a future version so knowing any caveats beforehand would be useful!

Read more comments on GitHub >

github_iconTop Results From Across the Web

"Device Timed Out" error in Sidecar - Apple Community
iPad, iPhone, and iPod touch: Go to Settings , then tap General > Handoff. · Mac: Choose Apple Menu > System Preferences >...
Read more >
Sidecar: Unable to Connect to iPad: The Device Timed Out, Fix
Sidecar “Unable to Connect, Device Timed Out” Error · iPad: Go to Settings > General > AirPlay & Handoff and ensure that Handoff...
Read more >
7 Ways to Fix Device Timed Out Error in Sidecar (Fast & Simple)
How to Fix “Device Timed Out” Error in Sidecar · 1. Hardware Compatibility. · 2. General Troubleshoot. · 3. Turn On or Off...
Read more >
[5 Tips] Fix: Screen Time Not Working on iPhone/iPad - iMobie
Method 2. Force Restart Your Device · Hold both the Home and the Top (or Side) buttons. · Wait for the Apple logo...
Read more >
Screen Time Not Working on iPhone/Android? [How to Fix]
Part 1: How to Fix Apple Screen Time Not Working? · 1 Disabled and Re-enabled Screen Time · 3 Enable Share Across Devices...
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