I have a Client-Server app, sending Data from an Android Phone, to a Tablet - Phone calls, SMS, Battery condition etc. The Phone is the Client, the Tablet the Server, and both run Services, with Partial WakeLocks to keep them alive for long enough, plus the Client has a PhoneStateListener, and a BroadcastReceiver to keep track of calls, Battery condition etc.
The point is that both ends stay alive, but at some stage - according to my logging set-up about 20 minutes - the Client reports that I have a "Broken Pipe".
On the Server side, I have a blocking Server, in a loop, listening for single byte commands from the Client, within a Thread, but I also added a Thread that runs once every minute find out what is causing the problem.
As the Client detects a broken pipe, I am assuming that there is a condition that the Server socket is in, that causes it, but I am testing the following -
- Whether the Socket is open or not.
- Whether the Input or Output Stream is open,
- Whether any of them are null.
Unfortunately, all of these conditions are fine, and it is as though the
connection is still active. What should I be looking for ?
What I want to be able to do is once the Client detects the "Broken Pipe", the Server does too, and attempts to re-connect.