Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stuck with Connecting state #178

Closed
kanat opened this issue Apr 21, 2017 · 22 comments
Closed

Stuck with Connecting state #178

kanat opened this issue Apr 21, 2017 · 22 comments
Assignees
Labels
bug Bug that is caused by the library

Comments

@kanat
Copy link

kanat commented Apr 21, 2017

conn_stuck_key.txt

Summary

Stuck with Connecting state

Preconditions

I'm just calling device.establishConnection(false)

Steps to reproduce actual result

  1. device.establishConnection(false)
  2. Unsubcribe
  3. device.establishConnection(false)
  4. Repeat again from 1 N times

Actual result

CONNECTING state

04-21 16:48:15.335 25090-25183/ru.starline.key E/ConnectionManager: (Key-1-1:2184) [connect] RxBleDeviceImpl{bluetoothDevice=StarLine BLE(F8:5B:60:89:CD:8A)} (autoConnect='false')

And I get

04-21 16:48:50.354 25090-25219/ru.starline.key E/ConnectionManager: (RxComputationScheduler-3:2194) [connect] error: BleGattCallbackTimeoutException{macAddress=null, bleGattOperationType=BleGattOperation{description='CONNECTION_STATE'}}

I don't understand why mac address is null

Also you can see at logs that Connection was established:
04-21 16:48:15.357 25090-25112/ru.starline.key D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=6 device=F8:5B:60:89:CD:8A
04-21 16:48:15.357 25090-25112/ru.starline.key D/RxBle#BluetoothGatt: onConnectionStateChange newState=2 status=0

Expected result

CONNECTED state

@dariuszseweryn
Copy link
Owner

Nice one. It seems to be a race condition in the RxBleRadioOperationConnect. I am writing a fix.

@dariuszseweryn dariuszseweryn self-assigned this Apr 21, 2017
@dariuszseweryn dariuszseweryn added the bug Bug that is caused by the library label Apr 21, 2017
@kanat
Copy link
Author

kanat commented Apr 24, 2017

Is it possible to configure timeout value for ble operation?
Now it takes about 35 seconds to get BleGattCallbackTimeoutException.

@dariuszseweryn
Copy link
Owner

From connection observable you can unsubscribe at any moment and it should be handled by the library.

@kanat
Copy link
Author

kanat commented Apr 25, 2017

Unsubscribing is not helping.

The result is even worse.
When I try to unsubscribe and subscribe again I'm not getting BleGattCallbackTimeoutException and stuck with CONNECTING forever.

@kanat
Copy link
Author

kanat commented Apr 25, 2017

As I understand the problem occurs here in RxBleRadioOperationDisconnect (line 62):

if (bluetoothGatt == null) {
    RxBleLog.w("Disconnect operation has been executed but GATT instance was null.");
    onCompleted();
}

After calling onCompleted the method releaseRadio is never called.

@dariuszseweryn
Copy link
Owner

True. Another thing that did not manifest before.

@timmiller17
Copy link

I think I am struggling with this as well. How is the fix coming along?

@dariuszseweryn
Copy link
Owner

Fix for the original cause is ready and waiting on a private PR to be reviewed by @uKL but he has a quite full plate at the moment. I hope that he will have a moment tomorrow to check it out. The fix for the manifestation (Disconnect) I will make tomorrow.

@kanat
Copy link
Author

kanat commented Apr 25, 2017

Is there any way to push my own ConnectionModule into the RxAndroidBle Graph?
(Just to provide fixed versions of operations, until official release will be published)

@dariuszseweryn
Copy link
Owner

Unfortunately - There is no possibility to do this. You would have to compile your own version from the sources.

@kanat
Copy link
Author

kanat commented Apr 25, 2017

What a pity.
That would be nice to have)

@kanat
Copy link
Author

kanat commented Apr 25, 2017

It seems to be a race condition in the RxBleRadioOperationConnect

@dariuszseweryn could you tell me what was the problem at RxBleRadioOperationConnect?

@dariuszseweryn
Copy link
Owner

RxBleGattCallback is emitting onConnectionStateChange() before the subscription chain is fully established.

dariuszseweryn added a commit that referenced this issue Apr 26, 2017
…BluetoothGatt` is available. #178

Reviewers: pawel.urban

Reviewed By: pawel.urban

Differential Revision: https://phabricator.polidea.com/D2325
dariuszseweryn added a commit that referenced this issue Apr 26, 2017
Summary: #178

Reviewers: pawel.urban

Reviewed By: pawel.urban

Differential Revision: https://phabricator.polidea.com/D2327
dariuszseweryn added a commit that referenced this issue Apr 26, 2017
Reviewers: michal.zielinski, pawel.urban

Reviewed By: pawel.urban

Differential Revision: https://phabricator.polidea.com/D2321
@dariuszseweryn
Copy link
Owner

@kanat I have pushed fixes for all issues found by you. These should be available in the 1.3.0-SNAPSHOT artifact shortly. Could you give it a try?

@kanat
Copy link
Author

kanat commented Apr 26, 2017

@dariuszseweryn yes, sure, I can try it with real device.
Where/How can I get 1.3.0-SNAPSHOT artifact?

@dariuszseweryn
Copy link
Owner

See https://github.com/Polidea/RxAndroidBle
Snapshot paragraph

@kanat
Copy link
Author

kanat commented Apr 26, 2017

Actually I've tried it with my own fixes, seems it works :)
Anyway I'll try 1.3.0-SNAPSHOT as well.

@kanat
Copy link
Author

kanat commented Apr 26, 2017

@dariuszseweryn It works, thanks.

@kanat
Copy link
Author

kanat commented Apr 26, 2017

@dariuszseweryn, is it possible to get frozen version of 1.3.0-SNAPSHOT, to avoid situation where my own app can be affected by new changes which can arrive with a modified SNAPSHOT?
Or maybe it's better to compile RxAndroidBle by my own, until the new release version will be published?

@dariuszseweryn
Copy link
Owner

Great news. I will try to publish 1.2.1 tomorrow. You are welcome.

Your own version will be more bulletproof. SNAPSHOTs tend to change but regression is rarely an issue.

@dariuszseweryn
Copy link
Owner

@kanat I have just released 1.2.1
It should be available shortly.

@kanat
Copy link
Author

kanat commented Apr 27, 2017

@dariuszseweryn Great news, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug that is caused by the library
Projects
None yet
Development

No branches or pull requests

3 participants