I am working on an Android application, which talks to a Bluetooth device over a OutputStream. This works fine, so long as the phone has an internet connection. However, if the phone looses it's internet connection, writing to said Output stream will often cause an "IOException - Broken pipe" to be thrown. Even stranger, the exception provides no stack trace, and the cause of the exception is just a reference to itself. Has anyone seen an issue like this before, or have any idea what it's cause might be? At the moment I am wondering if it is a bug in Android. Thanks
Asked
Active
Viewed 2,858 times
4
-
Obviously the device you're writing to has closed its end of the connection. – user207421 Nov 27 '16 at 22:10
-
I would assume this, however the device is not aware of the Android phone loosing internet connection. I don't sent it any packets indicating a lost connection, and none of the packets I send to it rely on data from the internet. – slayerpjo Nov 27 '16 at 22:18
-
I didn't say *why* it has closed the connection. It may have nothing to do with Internet loss. You may have sent it something it didn't understand, for example. Please edit the stack trace into your question. – user207421 Nov 27 '16 at 23:16
-
In my case the connection on the bluetooth device's side apparently gets broken if I transmit right away after creating the socket. I added delays in my Android code as a workaround and with the delays it now works fine. – axk Feb 26 '17 at 21:19
-
Thanks for the information, will have a go doing that. It seems to happen pretty sporadically, I also wonder if it may be dependent on phone model and Android version too – slayerpjo Feb 27 '17 at 00:41