Hi,
I am using the CC3220SF with SDK Version 2.40.02.00 and using the httpclient to connect post data to a server at a set rate. I've successfully gotten the device to post my data at my desired frequency, however after a certain amount of posts I begin to get error -10 preventing me from posting. According to slneterr.h this error is "SLNETERR_BSD_ENSOCK" which is "The system limit on the total number of open sockets, has been reached." This value is always returned from the HTTPClient_sendRequest or HTTPClient_connect function calls in my code. This leads me to believe that the sockets opened by the httpclient.c functions are not being properly closed, even though the HTTPClient_disconnect is supposed to close the socket that is used in the HTTPClient_Handle passed into it. I've added my code to this post, I have it set to run every minute. I'd appreciate any help I could get with this issue!
HTTPClient_Handle httpClientHandle;
bool moreDataFlag = false;
char data[HTTP_MIN_RECV];
int16_t ret = 0;
int16_t len = 0;
LOG_MESSAGE("Sending a HTTPS POST request to '%s'\r\n", HOSTNAME);
httpClientHandle = HTTPClient_create(&statusCode,0);
if(statusCode < 0){
printError("httpTask: creation of https client handle failed", statusCode);
continue;
}
ret = HTTPClient_setHeader(httpClientHandle,
HTTPClient_HFIELD_REQ_USER_AGENT,
USER_AGENT,strlen(USER_AGENT)+1,
HTTPClient_HFIELD_PERSISTENT);
ret = HTTPClient_setHeader(httpClientHandle, HTTPClient_HFIELD_REQ_CONTENT_TYPE,CONTENT_TYPE,strlen(CONTENT_TYPE),HTTPClient_HFIELD_PERSISTENT);
if(ret < 0){
printError("httpTask: setting request header failed", ret);
continue;
}
HTTPClient_extSecParams httpClientSecParams;
httpClientSecParams.rootCa = SSL_CA_CERT;
httpClientSecParams.clientCert = NULL;
httpClientSecParams.privateKey = NULL;
ret = HTTPClient_connect(httpClientHandle,HOSTNAME,&httpClientSecParams,0);
if(ret < 0){
printError("httpTask: connect failed", ret);
continue;
}
ret = HTTPClient_sendRequest(httpClientHandle,HTTP_METHOD_POST,REQUEST_URI,
post.msg,strlen(post.msg),
0);
if(ret < 0){
printError("httpTask: send failed", ret);
continue;
}
LOG_MESSAGE("HTTPS Response Code: %d\r\n", ret);
len = 0;
do
{
ret = HTTPClient_readResponseBody(httpClientHandle, data, sizeof(data),
&moreDataFlag);
if(ret < 0){
printError("httpTask: response body processing failed", ret);
continue;
}
LOG_MESSAGE("%.*s \r\n", ret, data);
len += ret;
}
while(moreDataFlag);
LOG_MESSAGE("Received %d bytes of payload\r\n", len);
ret = HTTPClient_disconnect(httpClientHandle);
if(ret < 0){
printError("httpTask: disconnect failed", ret);
continue;
}
HTTPClient_destroy(httpClientHandle);