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

You are here

BGS5T ServerSocketConnection Bug - Connection won't close when sending less than 24 Bytes | Thales IoT Developer Community

June 1, 2015 - 1:11pm, 2335 views

I'm showing a typical socket server code. Basically (with some things removed for better readability) I'm doing this in Java:

listener = (ServerSocketConnection)"socket://:" + port);

System.out.println("Local Address: " + listener.getLocalAddress());

while (true) {

  sc = (SocketConnection) listener.acceptAndOpen();

  in = new InputStreamReader(sc.openInputStream());

  // ... processing Input, preparing Output...

  out = new PrintStream(sc.openOutputStream());


  out.close(); in.close(); sc.close();


Now the buggy part is, if string response is less than 24 bytes long, the connection won't close, even though out.close(), in.close() and sc.close() are called; they don't throw an exception. **

I tested with netcat, where I can clearly see that the BGS5T closes the connection, when more or eqal than 24 bytes are sent, and that the connection hangs, when less than 24 bytes are sent. When it hangs, I can exit netcat only with CTRL+C.

I've tried all combinations of arrangement of out.close(), in.close(), sc.close(), with no luck. I've tried also .flush(), and also closing the underlying sockets (the ones opened with sc.openInputStream() and sc.openOutputStream()), with no luck. When less than 24 bytes are sent, the connections remains open.

I consider this behaviour as a bug. Is this behaviour also present in the EHSx models?

Kind regards,



** To add even more confusion, when testing with Local Debug Connection, this bug doesn't show up. It only shows with GPRS connection.