0

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.

RG01
  • 121
  • 1
  • 1
  • 9
  • I'd suggest you remove the whole `if(!InReader.ready())` part. You don't need preparations to read from a socket (same goes for `available()`, no need to use it ever). Then I'd suggest monitoring the network traffic. – Kayaman Jul 04 '21 at 08:30

1 Answers1

1

The problem was not a java issue. It had to do with the firmware of the GSM Module from the client.

RG01
  • 121
  • 1
  • 1
  • 9