I work on application which constantly sends some data acquired from device to server API. And I have a service working all the time in background and collecting data and then a network thread in this service which is responsible for establishing connection with server and sending data.
The problem I have is that although I acquire Wake and WiFi locks on service startup, at some point when device is on 3g network with poor connection it seems that socket write method just hangs: I see this from logs I output after each operation
Network thread is very simple and may be described as
while(true) {
if(!connectedToServer) {
connectToServer();
}
acquireData();
sendData();
}
And sendData is very simple - it writes data to socket output stream. From what I see in logs it seems that OutputStream.write() call just blocks for indefinite time on poor connection.
Did anyone experience similar problems?
Thanks,