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

Socket not created exception #19

Open
arajthala opened this issue May 4, 2017 · 2 comments
Open

Socket not created exception #19

arajthala opened this issue May 4, 2017 · 2 comments

Comments

@arajthala
Copy link

arajthala commented May 4, 2017

I am getting following exception when I'm not able to connect to bluetooth device and then I navigate to some other page. Is there any way to catch this exception in my code?

E/System:Uncaught exception thrown by finalizer
E/System: java.io.IOException: socket not created
at android.net.LocalSocketImpl.shutdownInput(LocalSocketImpl.java:404)
at android.net.LocalSocket.shutdownInput(LocalSocket.java:207)
at android.bluetooth.BluetoothSocket.close(BluetoothSocket.java:801)
at android.bluetooth.BluetoothSocket.finalize(BluetoothSocket.java:309)
at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:222)
at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:209)

mSubscriptionConnectDevice = mRxBluetooth.observeConnectDevice(mBluetoothDevice, uuid)
 .observeOn(AndroidSchedulers.mainThread())
 .subscribeOn(Schedulers.computation())
 .subscribe(new Action1 < BluetoothSocket > () {
  @Override
  public void call(BluetoothSocket bluetoothSocket) {
   try {
    mBluetoothConnection = new BluetoothConnection(bluetoothSocket);
    startReadingBluetoothData(); // this method starts read data subscription
   } catch (Exception e) { // This didn't catch any exception
    Log.e(TAG, "Error bluetooth connection:" + e.getMessage());
    if (bluetoothSocket != null) {
     try {
      bluetoothSocket.close();
     } catch (IOException e1) {
      Log.e(TAG, "IOException: " + e1.getMessage());
     }
    }
   }
  }
 }, new Action1 < Throwable > () {
  @Override
  public void call(Throwable throwable) {
   Log.e(TAG, "Error bluetooth connection: " + throwable.getMessage()); // I get this log message before getting that IOException : socket not created 
  }
 });
@arajthala
Copy link
Author

Actually, I'm trying to implement auto connect; so trying to reconnect the previously connected device in my service and i see this error if the bluetooth device is not in range or turned off.

@MaxKinny
Copy link

I try to do the same thing and meet the same question. Did you solve it?

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

2 participants