cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

tw-c-sdk needs internet connectivity before it will initialize.

rhodson
1-Visitor

tw-c-sdk needs internet connectivity before it will initialize.

I setup an experiment where our device connected to a wireless router, that had the internet disconnected from it. I implemented the tw-sdk as follows:

res = twApi_Initialize(server_url, port, URI, customer_key, NULL, MESSAGE_CHUNK_SIZE, MESSAGE_CHUNK_SIZE, TRUE);

res returns with the code 1004 - TW_HOST_NOT_FOUND

The question is when this happens I have to terminate the application and reload, but I want to store the messages in the offline message store instead, and have the sdk constantly try to reconnect, as this error would be considered a temporary issue. Is there any way to configure the SDK to accept messages while waiting for the connection to occur?

2 REPLIES 2
supandey
19-Tanzanite
(To:rhodson)

Hi Robert, by SDK accepting the messages you mean you wish to store them till the connection is back up? For C SDK the offline storage of messages is enabled by default have you already checked the settings for OFFLINE_MSG_STORE and OFFLINE_MSG_STORE_DIR for persisting them to ensure messages are not lost. Are there any errors?

I compiled the SDK with the OFFLINE_MSG set to 2. I verified the offline message storage functionality was operational. The error I illustrated above occurs during the twApi_Initialize functional call.

My software is written to call twApi_Initialize first, and wait for a TW_OK (error code 0) to be returned. When I attach to a network without internet access the initialization fails. I followed the examples provided within the SDK, as they also exit the main function with an error code if this function returns anything other than 0.

(Remember I am referring to the situation where the router has a temporary internet outage - not normal operation)


Here is my basic sequence-

res = twApi_Initialize(server_url, port, URI, customer_key, NULL, MESSAGE_CHUNK_SIZE, MESSAGE_CHUNK_SIZE, TRUE);

if ( res == TW_OK){

     twApi_DisableCertValidation(); <<<<<<<<< If I try doing this after twApi_Initialize returns the HOST_NOT_FOUND error, I seg fault.

     twApi_BindThing(thingName);

     twApi_RegisterProperty        

     twApi_RegisterService          

     twApi_PushProperties(TW_THING, thingName, proplist, -1, TRUE);<<<<<<<<<<<<< archive the readings

} else {

     exit (1);

}

I need to archive the reading in offline message storage - even if twApi_Initialize isn't done yet, or I will get a gap in my records as the rest of the system is active and wants to push data up to the server.



Announcements


Top Tags