SocketConnection KEEPALIVE socket option does not work | Telit Cinterion IoT Developer Community
November 30, 2015 - 8:52pm, 7715 views
Hi,
I've written a client socket connection to a TCP server. I want this connection to be open a long time so that the server can send me asynchronous events, as they are generated on the server side.
On the cellular network I operate, TCP connections are flushed from the NAT tables after 30 minutes of inactivity.
So, to prevent TCP connections from dropping after 30 minutes, I decided to use the keepalive socket option. The option doesn't allow you to specify the 3 options described in the TCP KEEPALIVE documentation (tcp_keepalive_time, tcp_keepalive_intvl, tcp_keepalive_probes). It only allows you to enable it or not, which is rather limited in my opinion - anyways.
So I enabled KEEPALIVE on my client SocketConnection instance by doing this, immediately after Connector.Open returned the instance:
socConn.setSocketOption(SocketConnection.KEEPALIVE, 1);
if(socConn.getSocketOption(SocketConnection.KEEPALIVE) == 0) {
// error handling: Close socket and return error.
}
But lo and behold, after 1 hour of waiting for a keepalive packet, I did not get any. I used tcpdump to verify this. Needless to say, by that time my TCP connection entry in had timed out in my operator NAT table and the connection was in limbo.
Inversely, I coded my own TCP server and implemented the KEEPALIVE TCP socket options (in C, linux) and tested with this. Keepalives were seen and kept my connection up for two hours.
Anyone else has issues with TCP KEEPALIVE using the SocketConnection?
I'm using the IMP-NG EHS5 Wireless Toolkit (cwnlib_1.0).
Thanks!
Hello,
Could you please send the ATI1 and AT^SCFG? replies.
So far I haven't found any reports connected with this socket option and no information that this should not be working.
Regards,
Bartłomiej
Thanks for your time, Bart,
ATI1
Cinterion
EHS5-US
REVISION 02.000
A-REVISION 00.000.15
OK
AT^SCFG?
^SCFG: "Call/ECC","0"
^SCFG: "GPRS/AutoAttach","enabled"
^SCFG: "Gpio/mode/ASC1","gpio"
^SCFG: "Gpio/mode/DAI","gpio"
^SCFG: "Gpio/mode/DCD0","gpio"
^SCFG: "Gpio/mode/DSR0","gpio"
^SCFG: "Gpio/mode/DTR0","gpio"
SCFG: "Gpio/mode/FSR","gpio"
^SCFG: "Gpio/mode/PULSE","gpio"
^SCFG: "Gpio/mode/PWM","gpio"
^SCFG: "Gpio/mode/RING0","gpio"
^SCFG: "Gpio/mode/SPI","gpio"
^SCFG: "Gpio/mode/SYNC","gpio"
^SCFG: "Ident/Manufacturer","Cinterion"
^SCFG: "Ident/Product","EHS5-US"
^SCFG: "MEShutdown/Fso","0"
^SCFG: "MEopMode/SoR","off"
^SCFG: "Radio/Band","108"
^SCFG: "Radio/OutputPowerReduction","0"
^SCFG: "Serial/Interface/Allocation","0","0"
^SCFG: "Serial/USB/DDD","0","0","0409","1E2D","0058","Cinterion Wireless Modules","EHx",""
^SCFG: "Tcp/IRT","3"
^SCFG: "Tcp/MR","10"
^SCFG: "Tcp/OT","6000"
^SCFG: "Tcp/WithURCs","on"
^SCFG: "Trace/Syslog/Otap","0"
^SCFG: "URC/Ringline","local"
^SCFG: "URC/Ringline/ActiveTime","2"
^SCFG: "Userware/Autostart","1"
^SCFG: "Userware/Autostart/Delay","0"
^SCFG: "Userware/DebugInterface","0.0.0.0","0.0.0.0","0"
^SCFG: "Userware/DebugMode","on"
^SCFG: "Userware/Passwd",
^SCFG: "Userware/Stdout","null",,,,"off"
^SCFG: "Userware/Watchdog","0"
Hi,
Anything I can do to help resolve this issue?
Thanks,
Charles
Hello,
This option was not working for old modules (TC65i, EGS5) but there was an information in the Java API.
For this module three's no such information.
There are updates for your firmware. You could try to test it with the latest firmware.
Regards,
Bartłomiej
Thank you,
I'll check it out!
Charles
Sadly after installing ehsx_rev03.001_arn0000014 things that used to work well now started not working.
Also getting unstable AT interface.
I reverted to my stable FW and things recovered. Although with the keepalive not working issue.
Can't you test it on your side? At least get confirmation I'm not the only one seeing this?
Thanks,
Charles
Hello,
There's newer software for revision 2 that should be better for your module: 02.000_arn0000019.
But as I can't see any records for this KEEPALIVE issue there may be no difference.
We will verify this.
Regards,
Bartłomiej
Very interresting.
Thanks for the heads up on the new software for my rev. I'll try to get my hands on it and let you know if things change.
Thanks,
Charles