XDK hangs after some http client GETs
Antwort
12.03.17 20:30

I used the HttpExampleClient to push to my own server.

WLAN works perfect and I can see my GET requests coming in my server.

The client runs for a couple minutes and then stops working. 

If I disable the httpclient part of the sample, it runs without problems (just printf in the timer loop)

Is there any known instability in the httpclient library ?

I am using Workbench Version 2.0.0

0 (0 Stimmen)
RE: XDK hangs after some http client GETs
Antwort
13.03.17 17:36 als Antwort auf Chris Muench.

Hello Chris,

Welcome to the XDK community.

The HttpExampleClient example should work right out of the box if you did not make any changes to it.
I did some stability tests this morning and it run over hours without any issues. Therefore I assume the issue is not related to the example itself.

I recommend to not rely on printfs in embedded environments.
They are not thread safe and in addition if you do not take care about all of them containing “\n\r” you can not be sure if further printfs are displayed.

How did you confirm that the http client is not working any more?
Did you obverse the communication something else than the printfs, Wireshark for example?

Kind regards,
Franjo

0 (0 Stimmen)
RE: XDK hangs after some http client GETs
Antwort
13.03.17 18:29 als Antwort auf Franjo Stjepandic.

I dont have any printfs in my httpSender or response methods.

I am using the LEDs to show when I am posting

When the XDK hangs, the sensor is completely unresponsive and has to be turned off/on to reset.

First I though it might have something to do that the XDK is very picky about HTML coming back in the response (must be HTML). But once I fixed that it still hangs after several minutes of sending.

 

Also: If I add

#include <Serval_HttpClient.h>

#include <Serval_RestClient.h>

both to my app, I get a compiler error in your Serval_Security.h:

enum SecurityConnection_e

{

 TLS = 0x0,  <= here it fails to compile with "expected identifier before '(' token"

 DTLS = 0x1,

};

typedef enum SecurityConnection_e SecurityConnection_t;

 

The REST client does not work at all in my environment. (or is it possible that you do not allow httpclient and RESTclient in the same app as the error above suggests?)

Is there a limit how often a HTTPRequest can be sent? I am trying to send every 500ms

 

My guess is that somewhere the memory gets corrupted but if I just drop the "HttpSendString()" (see below) the app runs without problems multiple hours.

 

Here my httpsendString(): (*pUrl_ptr contains a path+query; FRPort and DestAddr are determined elsewhere. and do not change)

void HttpSendString(char *pUrl_ptr)

{

Msg_T* msg_ptr;

Ip_Port_T destPort = (Ip_Port_T)FRPort; // DEST_PORT_NUMBER;

static Callable_T SentCallable;

retcode_t rc = RC_OK;

 

LED_setState(orangeLedHandle, LED_SET_ON);

 

Callable_T * Callable_pointer;

Callable_pointer = Callable_assign(&SentCallable, callbackOnSent);

if (Callable_pointer == NULL)

{

// printf("Failed Callable_assign\r\n ");

IsConnecting=false;

return;

}

rc = HttpClient_initRequest(&destAddr, Ip_convertIntToPort(destPort), &msg_ptr);

 

if (rc != RC_OK || msg_ptr == NULL)

{

//printf("Failed HttpClient_initRequest %i to port %i \r\n ",rc, destPort);

IsConnecting=false;

return;

}

 

HttpMsg_setReqMethod(msg_ptr, Http_Method_Get);

rc = HttpMsg_setReqUrl(msg_ptr, pUrl_ptr);

if (rc != RC_OK)

{

//printf("Failed to fill message \r\n ");

IsConnecting=false;

return;

}

 

rc = HttpClient_pushRequest(msg_ptr, &SentCallable,//null);

httpClientResponseCallback);

if (rc != RC_OK)

{

//printf("Failed HttpClient_pushRequest \r\n ");

IsConnecting=false;

return;

}

}

 

And the OnSent

static void onRESTRequestSent(Msg_T *msg_ptr, retcode_t status) {

( void) msg_ptr;

if (status != RC_OK)

{

//printf("Failed to send REST request!\r\n");

}

LED_setState(orangeLedHandle, LED_SET_OFF);

IsConnecting=false;

}

 

0 (0 Stimmen)
RE: XDK hangs after some http client GETs
Antwort
15.03.17 09:57 als Antwort auf Chris Muench.

Hello Chris,

I guess I misunderstood your statement about the printfs. As I mentioned earlier I tested the example over an hour and it worked without any issues. But I guess in your case your are dealing with an old example project of the Workbench 1.7 which includes a deprecated version of the Serval_Security.h interface.

Thus I recommend to save your changes and to re-import the HttpExampleClient project from the welcome screen again. Insert your code changes and give it another try. This should also fix that you can use both includes of the REST and HTTP API. If this is not the case, I recommend to implement both based on a clean XdkApplicationTemplate and try it again.

Related to your issue about the time between HTTP requests: 
It depends on how long the filling of your HTTP request takes. I would not recommend to set the time intervall shorter than the request time.

Please tell me if this helps you and do not hesitate to ask if you have further questions.

Kind regards,
Franjo

0 (0 Stimmen)
RE: XDK hangs after some http client GETs
Antwort
15.03.17 02:28 als Antwort auf Franjo Stjepandic.

I only used Workbench 2.0.0 and just today updated to 2.0.01. The sample was taken brand new from the 2.0.0 workbench (i never worked with anything older).

I will try your recommendation on the clean template...and let you know.

On the "interval" I do ensure that there is no other GET happening until I reveive the "SENT" callback. I do not wait for the "response" though...that is not how REST/HTTP should work. Are you telling me you are holding state between the Request and Response that makes it impossible to send another Request before the previous REsponse has completed? If so your http implementation is quite unsuable with Wifi as there is no garantee if the response ever happens (not required for GET).

IN fact I dont need the Response ever since I only post outbound and do not require a response. But setting the Response Callback to null did not help with my setup.

 

Let me see if the other template works better

Thanks

Chris

0 (0 Stimmen)
RE: XDK hangs after some http client GETs
Antwort
15.03.17 17:17 als Antwort auf Chris Muench.

Hello Chris,

the sending of HTTP requests and responses is implemented asynchronous, of course!
Thus you do not have to wait until you receive the HTTP response to send your next HTTP request.

In general, there is not limitation. But assume your server has a response time of 500 ms. If you send a request each 100ms, it can lead to memory management issues or any other unknown behavior (not only on the XDK side).
Thats why I would recommend to stay above the response time of your server with your sending interval. But it depends on your use case.

Meanwhile please keep me posted about your progress with the clean HTTP implementation.

Please tell me if this is helpful and do not hesitate to ask if you have further questions.

Kind regards,
Franjo

0 (0 Stimmen)
RE: XDK hangs after some http client GETs
Antwort
15.03.17 23:40 als Antwort auf Franjo Stjepandic.

Thanks for your fast answer, Franjo

Unfortunately recreating the app from scratch did not help (using the blank Template).

We tested it now with 3 XDKs on 4 different PC with different Wifi Dongles (for the Server side) all show the same problem that the HttpClient_InitRequest() hangs so badly that the whole XDK sensor becomes unresonsive (no timer fires, no Button-Callback is called).

The time until it happens varies between 10 sekonds to 44minutes. But most of the time it happen in the first 5 minutes.

Our server can handle calls in very few milliseconds and is tuned for IoT scenarios (we are an Industrial IoT Company and the server is part of our distributed IoT Platform www.c-labs.com)

We continue to look into this as we would love to show the sensor connected to our IoT Factory-Relay product at the Hannover Messe in April

 

Thanks

Chris

 

0 (0 Stimmen)
RE: XDK hangs after some http client GETs
Antwort
16.03.17 00:08 als Antwort auf Chris Muench.

BTW: I still get the compile error in Serval_Security.h:

./../Libraries/ServalStack/ServalStack/api/Serval_Security.h:92:2: error: expected identifier before '(' token

I completely removed the Workbench and reinstalled it. The only way to fix this was to comment out lines 90-95 in serval_security.h and change line 199 to:

uint8_t connection:1;

These are the headers I include:

/* system header files */

#include "BCDS_Basics.h"

 

/* additional interface header files */

#include "FreeRTOS.h"

#include "timers.h"

 

/* additional interface header files */

#include "led.h"

#include "button.h"

#include "XdkBoardHandle.h"

#include "BCDS_Accelerometer.h"

#include "simplelink.h"

 

#include "PAL_initialize_ih.h"

#include "PAL_socketMonitor_ih.h"

#include "BCDS_WlanConnect.h"

#include "BCDS_NetworkConfig.h"

#include <Serval_HttpClient.h>

#include <Serval_RestClient.h>

#include <Serval_Network.h>

#include "XdkSensorHandle.h"

0 (0 Stimmen)
RE: XDK hangs after some http client GETs
Antwort
17.03.17 12:44 als Antwort auf Chris Muench.

Hello Chris,

It seems that you made more changes in the HttpExampleClient example as I expected. I assume you are dealing with more issues than only with the Serval_Security.h interface.

Thus I think the best possibility would be to share your code to reproduce and analyze the issues in detail. In addition I would like to clarify if this is an issue directly related to the API to improve it, if this is the case.

I would ask you to post your email address in here that I can contact you.

Kind regards,
Franjo

0 (0 Stimmen)
RE: XDK hangs after some http client GETs
Antwort
18.03.17 00:13 als Antwort auf Franjo Stjepandic.

Thanks Franjo

my email is: muenchris@hotmail.com

 

is there a chance that the XDK is not working properly with Wifi AC hotspots (mine does support a/b/g/n/a/c)

Or that it has problems with US Wifi Bands (particular channel 11)?

 

Thanks

Chris

0 (0 Stimmen)
RE: XDK hangs after some http client GETs
Antwort
21.03.17 07:54 als Antwort auf Chris Muench.

Hello Chris,

Thank you for providing your email address. I have contacted you already.
Furthermore I guess the XDK is not able to work within the new Wi-Fi standard including AC hot spots. But I think that they are downward compatible and thus the XDK should work fine when connecting to such an particular AC hot spot. Although is the underlaying Wi-Fi API a product of Texas Instruments and should also work correctly with US Wi-Fi bands.

Please tell me if this is helpful and do not hesitate to ask if you have further questions.

Kind regards,
Franjo

0 (0 Stimmen)
RE: XDK hangs after some http client GETs
Antwort
25.03.17 18:45 als Antwort auf Franjo Stjepandic.

I'm getting this error too. Solved it by not including the serval rest client. I wasn't provided with a satisfactory solution either.

./../Libraries/ServalStack/ServalStack/api/Serval_Security.h:92:2: error: expected identifier before '(' token

 

Chris, I've also coded a similar program. Which basically sends HTTP post messages every second. Let me know if you're interested in taking a look.

0 (0 Stimmen)
RE: XDK hangs after some http client GETs
Antwort
05.04.17 13:39 als Antwort auf Lee Weiyang.

Hello XDK community,

Chris sent me his project and I performed a test, if the HTTP and Wi-Fi implementation of the XDK causes any issue with the new Wi-Fi ac standard.

I used as test environment a TP-LINK AC1750 Dual Band Wireless router and a Raspberry Pi.

The TP-Link router was configured to be WPA2 encrypted in both 2.4 GHz and 5 GHz.

The Raspberry Pi was used to run a simple HTTP server implementation.

I used the HttpExampleClient example as test code to ensure that the implementation is not the cause of the issue. Further I analyzed Chris's HTTP code and run the same test.

Both tests ran over an hour and and both HTTP and Wi-Fi worked without any occurring failure. Therefore I can ensure that on the XDK side the HTTP and Wi-Fi implementation are working without issues.

In addition, I can tell that the simplelink Wi-Fi chip CC3100 within the XDK only supports the 2.4 GHz Wi-Fi standard. Thus it results that it is no router issue too, because the new ac standard is only available within 5GHz.

Therefore I assume, Chris's issue is caused by a network overload or server failure.

Additionally some hints for you Chris, about your application code.

I had some starting issues to build your application code correctly. This resulted because the project was not correctly renamed. I recommend to take a look at the section 5.4 Rename a Project in the XDK Workbench in the First Steps guide to get familiar with that.
In addition, I encountered an issue with Serval_Security.h while building. The issue occurs by including Serval_RestClient.h as well as including simplelink.h. To quick fix this, I removed the unused include and any other unused code which uses functinality of the Serval_RestClient.h interface.
I will take a closer look at this issue about the includes, but for now I recommend to avoid combinations of simplelink.h and Serval_RestClient.h functionality in your application code.

I hope this is helpful and please do not hesitate to ask if you have further questions.

Kind regards,
Franjo

0 (0 Stimmen)
RE: XDK hangs after some http client GETs
Antwort
05.04.17 15:21 als Antwort auf Franjo Stjepandic.

Hello Franjo,

 

thanks for your analyses. I am still not sure if that helps. The XDK hangs completely in my environment - so bad that the buttons will no longer fire their callbacks. The only way to "un hang" it is to restart the XDK. That is not something I do in my code for sure.

The server is not having any issues as its dedicated to the XDK and even has its own hotspot. So there is neither an overload nor a connectivity issue.

The question remains of your internal chip is working properly with the american Wifi standard. The TP-LINK AC... is different in Germany to the US Version

 

Cheers

Chris

0 (0 Stimmen)
RE: XDK hangs after some http client GETs
Antwort
07.04.17 16:18 als Antwort auf Chris Muench.

Hello Chris,

the hotspots in Germany are indeed different to the ones in the US, but the CC3100 should be able to operate with both of them. We have a decent number of Americans here in the community and this is the first time anything like your issue has come up.

The US Wi-Fi hotspots are in particular limited to 11 channels. Due to my knowledge the CC3100 does automatic channel selection. This should not cause any connection aborts.

Are there any other routers nearby sending on the same channel? If there are, did you test your application in a more secluded environment? Does your hotspot provide sufficient signal strength?
Did you test your application with different routers? Did this change it’s behavior?

 

Please tell me if this is helpful and do not hesitate to ask if you have further questions.

Kind regards,
Franjo

0 (0 Stimmen)
RE: XDK hangs after some http client GETs
Antwort
14.04.17 18:22 als Antwort auf Franjo Stjepandic.

I followed all your guidlines and tried it on three other routers and channels. No Change in behavior!

I still get a hang right after "HTTP Sent..." - so badly that the XDK is not responding to ANYTHING anymore. THe XDK workbench "Reboot" or "Goto Bootloader" do not make the XDK to respond.

I can only turn it off and back on.

Since I have three XDKs and all three show the same behavior I doubt that its a hardware problem (except I got a bad badge of them).

Is there any way to set a "Timeout" on the Http Get request that calls my code if the http did not return in a given time?

 

0 (0 Stimmen)
RE: XDK hangs after some http client GETs
Antwort
14.04.17 20:52 als Antwort auf Chris Muench.

I switched to Static IP for the XDK and now it seems much more stable...running for hours now.

Is the "null" on the DHCP Callback a good idea?

        ReturnValue = NetworkConfig_SetIpDhcp(NULL);

If the call is synchronous it should not matter but if not, the IP might not be set on slow networks and later when the DHCP setup is done the HttpClient gets confused (thread safe??)

 

Also i do get 0x44c sometimes on the http_initRequest but I cannot find out what that error means. Is there somewhere a lookup for these codes?

And finally: When is the stack ready for the next httpClient_initRequest? Right away? After the "callbackonsent" was completed? or even only after the responsecallback was processed?

is LED_setState() thread safe because I call that in several of the callbacks (timer, keys and http-response callbacks)?

 

 

0 (0 Stimmen)
RE: XDK hangs after some http client GETs
Antwort
19.04.17 10:35 als Antwort auf Chris Muench.

Hello Chris,

I am glad to hear that your application is stable with static IP.
The DHCP callback is not necessarily needed to ensure DHCP is set correctly on the XDK. It is only used to deliver the acquired IP for the application purpose. Regarding your question about the thread safety, the underlaying simple link library is not implemented thread safe as well as NetworkConfig_SetIpDhcp(NULL).

LED_setState() is not implemented thread safe, too. The function only provides the basic functionality to manipulate the LEDs on the XDK.

If you require thread safety, then you could implement it by using semaphores. These are provided by FreeRTOS to implement thread safety, within the application.  

Regarding your second questions about the error code: You can take a look at the interface Serval_Exceptions.h. All error codes for every protocol are listed here, and it includes a small description on how to read them, too. You can find the interface here:

SDK > xdk110 > Libraries > ServalStack > ServalStack > api

I assume that you can start the next execution of HttpClient_initRequest() right after callbackonsent is complete. Response callback and the sending functionality are working asynchronously. Thus you do not need to wait until the response callback is evaluated.

Please tell me if this is helpful and do not hesitate to ask if you have further questions.

Kind regards,
Franjo

0 (0 Stimmen)