Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

question about responseStatusCode #9

Open
krapp70 opened this issue Mar 13, 2014 · 11 comments
Open

question about responseStatusCode #9

krapp70 opened this issue Mar 13, 2014 · 11 comments

Comments

@krapp70
Copy link

krapp70 commented Mar 13, 2014

Hi,
I am a newbie of github, so I apologise if I am using this issue tracking to ask a question...

I am using Arduino UNO + Ethernet Shield + xively library (https://github.com/xively/xively_arduino, that it is based upon the HttpClient library) to put some temperature data from a sensor to the xively platform.

Everythig works fine except that happens once in while (sorry... let's say randomly) that Arduino hangs on the xively put function, which recall the HttpClient put + sendHeader + endRequest + responseStatusCode + flush + stop functions.

The question is:
I modified the responseStatusCode adding a timeout condition on the while loop for the informational status code

while ( (iState == eStatusCodeRead) && (iStatusCode < 200) && 
           ( (millis() - timeoutStartResponse) < iHttpResponseTimeout ));

and I don't have freezes anymore, but I am sure (I do not know the http protocoll) that there is a better solution for this problem, maybe it's a server problems, and I would like to know what you think about.

thanks
best regards
Federico

@innovup
Copy link

innovup commented Mar 14, 2014

this is not my library, I only fork it. But I also have some troubles with
it. I think all troubled come from lack of RAM (not program size). You
shoud reduce number of variables and recurse function calls.

2014-03-14 2:29 GMT+04:00 krapp70 [email protected]:

Hi,
I am a newbie of github, so I apologise if I am using this issue tracking
to ask a question...

I am using Arduino UNO + Ethernet Shield + xively library (
https://github.com/xively/xively_arduino, that it is based upon the
HttpClient library) to put some temperature data from a sensor to the
xively platform.

Everythig works fine except that happens once in while (sorry... let's say
randomly) that Arduino hangs on the xively put function, which recall the
HttpClient put + sendHeader + endRequest + responseStatusCode + flush +
stop functions.

The question is:
I modified the responseStatusCode adding a timeout condition on the while
loop for the informational status code

while ( (iState == eStatusCodeRead) && (iStatusCode < 200) &&
( (millis() - timeoutStartResponse) < iHttpResponseTimeout ));

and I don't have freezes anymore, but I am sure (I do not know the http
protocoll) that there is a better solution for this problem, maybe it's a
server problems, and I would like to know what you think about.

thanks
best regards
Federico


Reply to this email directly or view it on GitHubhttps://github.com//issues/9
.

Михаил Богатырев
Digital Park
http://dipark.ru

@tvillingett
Copy link

something like this then?

unsigned long timeoutStartResponse = millis();
while ( (iState == eStatusCodeRead) && (iStatusCode < 200) && 
       ( (millis() - timeoutStartResponse) < iHttpResponseTimeout ));

Me too have problems with Xively timing out after about 1 week of continous upload to Xively server.

/Anders

13 mar 2014 kl. 23:29 skrev krapp70 [email protected]:

Hi,
I am a newbie of github, so I apologise if I am using this issue tracking to ask a question...

I am using Arduino UNO + Ethernet Shield + xively library (https://github.com/xively/xively_arduino, that it is based upon the HttpClient library) to put some temperature data from a sensor to the xively platform.

Everythig works fine except that happens once in while (sorry... let's say randomly) that Arduino hangs on the xively put function, which recall the HttpClient put + sendHeader + endRequest + responseStatusCode + flush + stop functions.

The question is:
I modified the responseStatusCode adding a timeout condition on the while loop for the informational status code

while ( (iState == eStatusCodeRead) && (iStatusCode < 200) &&
( (millis() - timeoutStartResponse) < iHttpResponseTimeout ));
and I don't have freezes anymore, but I am sure (I do not know the http protocoll) that there is a better solution for this problem, maybe it's a server problems, and I would like to know what you think about.

thanks
best regards
Federico


Reply to this email directly or view it on GitHub.

@krapp70
Copy link
Author

krapp70 commented Mar 14, 2014

Hi,
the snippet I posted was just to let you see I added the timeout:

(millis() - timeoutStartResponse) < iHttpResponseTimeout )

.. obviously I added at the beginning of the loop the definition of the variable

unsigned long timeoutStartResponse = millis()).

Anyway I think it's not a memory problem, I monitored the RAM but seen no leakage while after I modified the code adding the timeout I had no more problem. But I was looking for a better solution!

thanks
Federico

@tvillingett
Copy link

When I move the declaration to the place as the other timeout I get compile error:
unsigned long timeoutStart = millis();
unsigned long timeoutStartResponse = millis();

/Users/tvillingett/Documents/Arduino/libraries/HttpClient/HttpClient.cpp:384: error: 'timeoutStartResponse' was not declared in this scope

I might need some more coffee... I'm code blind at the moment, please tell me where you put it :)

/Anders

14 mar 2014 kl. 09:00 skrev krapp70 [email protected]:

Hi,
the snippet I posted was just to let you see I added the timeout:

(millis() - timeoutStartResponse) < iHttpResponseTimeout )

.. obviously I added at the beginning of the loop the definition of the variable

unsigned long timeoutStartResponse = millis()).

Anyway I think it's not a memory problem, I monitored the RAM but seen no leakage while after I modified the code adding the timeout I had no more problem. But I was looking for a better solution!

thanks
Federico


Reply to this email directly or view it on GitHub.

@krapp70
Copy link
Author

krapp70 commented Mar 14, 2014

ops, sorry :)
As soon as I come back home (I haven't still pushed the code on gitHub) I send the complete code.

bye
Federico

@tvillingett
Copy link

I had some coffee now, and placed it right. It works with both compile and downloading to my arduino.
In a week I will know if it is better than before.

Thanks!

/Anders

14 mar 2014 kl. 10:46 skrev krapp70 [email protected]:

ops, sorry :)
As soon as I come back home (I haven't still pushed the code on gitHub) I send the complete code.

bye
Federico


Reply to this email directly or view it on GitHub.

@krapp70
Copy link
Author

krapp70 commented Mar 14, 2014

OK. Let me know. With this modification my Arduino has been putting data on xively for more than a week without freezing. But I am looking for a better solution, let's say I just worked empirically :)

bye
Federico

@chaveiro
Copy link

Hello,

Your solution with the timeout is fine and good practice, if you want to
dig it, i recommend to debug each var value on that while variables to see
what value comes that affects it. Where to you set that vars ? Are you not
reaching some part of the code on a particular situation?
http://www.w3.org/Protocols/HTTP/HTRESP.html

Also i have trobble with the ethernet shield locking in the summer due to
build up temperature, requiring hard reset but thats another thread.

Regards,
Chaveiro

2014-03-13 22:29 GMT+00:00 krapp70 [email protected]:

Hi,
I am a newbie of github, so I apologise if I am using this issue tracking
to ask a question...

I am using Arduino UNO + Ethernet Shield + xively library (
https://github.com/xively/xively_arduino, that it is based upon the
HttpClient library) to put some temperature data from a sensor to the
xively platform.

Everythig works fine except that happens once in while (sorry... let's say
randomly) that Arduino hangs on the xively put function, which recall the
HttpClient put + sendHeader + endRequest + responseStatusCode + flush +
stop functions.

The question is:
I modified the responseStatusCode adding a timeout condition on the while
loop for the informational status code

while ( (iState == eStatusCodeRead) && (iStatusCode < 200) &&
( (millis() - timeoutStartResponse) < iHttpResponseTimeout ));

and I don't have freezes anymore, but I am sure (I do not know the http
protocoll) that there is a better solution for this problem, maybe it's a
server problems, and I would like to know what you think about.

thanks
best regards
Federico

Reply to this email directly or view it on GitHubhttps://github.com//issues/9
.

@krapp70
Copy link
Author

krapp70 commented Mar 14, 2014

Yes, you are right... but I dont' have much free time to debug :)

At the beginning I thought was a memory problem, so I monitored for a while the RAM, but everything seemed fine. I also wanted to trace the sever response via Serial, but the freeze was radom (maybe after 2/3 days). Then I looked up to write a log in the SD, but I had some problem with the SD library!

At the end I just gave a look to the code and added the time out where I thought it could be the problem. It worked, but I wrote this post becasue it looks like a wierd problem.

As I wrote I do not know the HTTP protocol (thanks fo the link) and I am just having fun once in a while with arduino & C.; it has to remain at a fun level!

Let's wait the test of tvillingett :)

thanks
Federico

@tvillingett
Copy link

Sorry to say that my test did fail. It failed after about 8h. We need to have a way to do some kind of debugging, with logging. There is a problem with the limited resources.

/Anders

14 mar 2014 kl. 21:42 skrev krapp70 [email protected]:

Yes, you are right... but I dont' have much free time to debug :)

At the beginning I thought was a memory problem, so I monitored for a while the RAM, but everything seemed fine. I also wanted to trace the sever response via Serial, but the freeze was radom (maybe after 2/3 days). Then I looked up to write a log in the SD, but I had some problem with the SD library!

At the end I just gave a look to the code and added the time out where I thought it could be the problem. It worked, but I wrote this post becasue it looks like a wierd problem.

As I wrote I do not know the HTTP protocol (thanks fo the link) and I am just having fun once in a while with arduino & C.; it has to remain at a fun level!

Let's wait the test of tvillingett :)

thanks
Federico


Reply to this email directly or view it on GitHub.

@krapp70
Copy link
Author

krapp70 commented Mar 15, 2014

oh... I am sorry.
Anyway I don't think it's a resources problem, I only modified the loop and it's been almost a week Arduino is sending data to xively, day and night, once every ten minutes; if the timeout is not the solution then I would say that, in my case, was a server problem.

As soon as I get some time I will try to compile the skecth with the original httpclient library and see if it freezes.

If you want to give a look my sketch you can find it at https://github.com/krapp70/arduino_test_repo/tree/master/test_vari2/test_xively5 (don't mind the code about the leds, it's just for my kids) and this is what I am using:

-Arduino UNO
-Arduino Ethernet Shield
-Xively Library (https://github.com/xively/xively_arduino)
-HttpClient Library modified (https://github.com/krapp70/HttpClient)

bye
Federico

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants