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

connect exception #29

Open
xiaolingcong opened this issue Dec 5, 2017 · 5 comments
Open

connect exception #29

xiaolingcong opened this issue Dec 5, 2017 · 5 comments

Comments

@xiaolingcong
Copy link

when bluetoothSocket.connect();
log:
getBluetoothService() called with no BluetoothManagerCallback
java.io.IOException: read failed, socket might closed or timeout, read ret: -1

@IvBaranov
Copy link
Owner

Discovering process could be an issue as it is a heavyweight procedure.
Make sure you wait until it is over or use BluetoothAdapter.cancelDiscovery().

Discovery is not managed by the Activity, but is run as a system service, so an application should always call {@link BluetoothAdapter#cancelDiscovery()} even if it did not directly request a discovery, just to be sure.

@Muhammad-Soban
Copy link

Same error as @xiaolingcong

 rxBluetooth.observeConnectDevice(device, UUID.fromString("00001101-0000-1000-8000-00805f9b34fb"))
                    .observeOn(AndroidSchedulers.mainThread())
                    .subscribeOn(Schedulers.io())
                    .subscribe(new Consumer<BluetoothSocket>() {
                      @Override
                      public void accept(BluetoothSocket socket) throws Exception {
                        // Connected to the device, do anything with the socket
                        Log.e("B", "Connected");
                      }
                    }, new Consumer<Throwable>() {
                      @Override
                      public void accept(Throwable throwable) throws Exception {
                        // Error occured
                        Log.e("B", "Error:  " + throwable.getLocalizedMessage());
                      }
                    });

E/B: Error: read failed, socket might closed or timeout, read ret: -1

It is only connecting with my macbook and HC-06 Bluetooth Module but not with any other Bluetooth device like Android.

I think the issue is with UUID because supported UUID list doesn't show UUID that I have coded as Base UUID in code. Any suggestions?

@IvBaranov
Copy link
Owner

@Muhammad-Soban try to generate your own unique UUID while connecting two Android devices.

@Gyurme
Copy link

Gyurme commented May 30, 2018

If you are connecting to a Bluetooth headset or similar device and if the regular UUIDs don't work , you must first query it for it's supported UUIDs and then use that to connect to it.

@NunciosChums
Copy link

NunciosChums commented Feb 15, 2019

I have same error. I'm use SPP + BluetoothProfile.HEADSET.
when call rxBluetooth.connectAsClient(device, UUID_SPP) => getBluetoothService() called with no BluetoothManagerCallback

but add .retryWhen { it.delay(500, TimeUnit.MILLISECONDS) }, always successfully connected after 30 second.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants