We use wip_TCPClientCreateOpts to create a connection to a server via GPRS whenever there is data to send. The socket connection is not kept open, but closed as soon as the is sent. We use a timer to open the connection when needed. The timer runs every 3 seconds.
The above works exactly as expected, except if the server is stopped for an hour or more. Instead of getting the normal WIP_CEV_ERROR event with WIP_CERR_TIMOUT error code, the wip_TCPClientCreateOpts call fails immediately (returns NULL). At this point, GPRS is still up as indicated by AT+CGREG and AT+CGATT.
Since there is no valid channel, I cannot call wip_getOpts to get the error, so how do we diagnose this?
Some additional info: After resetting the unit, wip_TCPClientCreateOpts is called 15 times and causes a WIP_CEV_ERROR event. Call 16 and onwards returns NULL and no events are generated.
Are you correctly closing and finalising the TCP connection before creating a new one? There is a maximum number of simultaneous TCP clients allowed, so if they are not being correctly closed, you may be reaching the limit.
Thanks, I think you’ve pointed me in the right direction. It looks like we’re only calling wip_close on the channel if it is in WIP_CSTATE_READY or WIP_CSTATE_TO_CLOSE state. I’ll call it regardless of the state.