I experienced a strange behavior when connecting via a TCP/IP socket over GSM/LTE. I have various distributed applications. They all connect through TCP/IP to my server. Immediately when the connection is established the client sends a connection string. This usually takes just 1-2 seconds to arrive at the server. Sometimes this takes 30 sek. Is there a known reason for the delay or does somebody experience the same problem?
...
inReader = new BufferedReader(new InputStreamReader(clientSocket.getInputStream(),"ISO-8859-1"));
...
lTimeCheck[2]=System.currentTimeMillis();
//if interface not ready - wait 2 sek
if (!inReader.ready()) {
try {
Thread.sleep(2000);
} catch (InterruptedException e) { }
}
//wait for first line
while (!isBrowser && !isStopped && (strVar = inReader.readLine()) != null) {
lTimeCheck[3]=System.currentTimeMillis();
Between lTimeCheck[2] and lTimeCheck[3] it normally takes 0 or 2 Sek. But sometimes it takes 30 Sek. Any suggestions are welcome.