Gemalto is now part of the Thales Group, find out more.

You are here

"(SocketConnection) Connector.open(openParm);" freezes . | Thales IoT Developer Community

October 28, 2021 - 4:52pm, 1148 views

Dear,

  I am  using an MTX-T device  

  Cinterion EHS6

My program opens the socket in a TimerTask and normally works fine. It opens the socket, sends data frames to server, closes the socket, ends the run procedure and until the next activation of the TimerTask.

This is how it works normally, but sometimes it freezes when opening the socket, without throwing an exception.

This is the portion of the code that opens the socket.

 public boolean GSMConnect() {
        try {
            String openParm = "socket://" + destHost + ":" + destPort+ ";" + connProfile;
            System.out.print("GSMCom.GSMConnect: " + openParm);
            synchronized(gsmLock){
                System.out.print(" Conn 1 ");
                sc = (SocketConnection) Connector.open(openParm);
                System.out.print(" Conn 2 ");
                is = sc.openInputStream();
                System.out.println(" Conn 3 ");
                os = sc.openOutputStream();
            }
            return true;
        }   catch (Exception e) { e.printStackTrace();
            System.out.println("GSMCom.GSMConnect Error: " + e.getMessage());
            return false;
        }
    }

How can I prevent the program from freezing in this procedure (Connector.open)?

If I can't stop it from freezing, could I force close the TimerTask and open a new one?

Best regards.