Creating a reliable TCP Connection | Telit Cinterion IoT Developer Community
November 17, 2017 - 10:22am, 8850 views
Hi all,
I'm currently writing an application for the EHS6T board that is gathering data via a serial port and outputting over a TCP connection.
Currently I am using a SocketConnection and an OutputsSream as in the examples I have seen, however this doesn't seem to be the correct way of doing it as the OutputStream write function will block indefinately if I lose cell reception.
Am I missing something obvious or is this method not the best approach for my requirements? Obviously in case of losing the connection I want to buffer the data and then send it when I can re-establish the connection.
Thanks in advance.
Please check your email.
Hi Bartłomiej,
Thanks I recieved the email and have upgraded, unfortunately no change. If I close the server end I imediately get an IOException when trying to send, however if I unscrew the Antenna to simulate losing signal it just sits blocking forever on trying to send.
Have you been able to replicate the issue by unscrewing the antenna?
Thanks again.
Hello,
I've been disconnecting the antenna but maybe my scenario was a little bit different.
Anyway if you still get this problem you may need to implement some kind of timer to kill such a connection if it takes too long.
You may also use BearerControlListener interface to control the state of bearer when this happens and see if the bearer is lost or not. You might also try to use BearerControl class to disconnect the bearer in such case - maybe it will speed up the exception.
Best regards,
Bartłomiej