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

YUN: Errors executing Curl or Client.get via Bridge: different behaviors based on length of commands/URL #1924

Closed
roger77 opened this issue Mar 11, 2014 · 2 comments
Assignees
Labels
Library: Bridge The Bridge Arduino library

Comments

@roger77
Copy link

roger77 commented Mar 11, 2014

I got some strange behavior out of executing curl commands via Arduino to send data via json GET requests. I was also able to replicate the exact problem just by invoking the Client.get() function on a ever increasing URL.
In particular if the total URL length is less than 300 the request executes correctly. Strangely enough, it also execute correctly if the URL length is greater than 500 and less than 800 characters. All URL longer than ~800 will just fails to be executed. Another odd behavior happens when the URL length is between 300 and 500 characters: the request will succeed but its execution time will always take more than 10 sec (see table below). This behavior happens either if I send request to my own server or if I direct the request to echo.jsontest.com.

I simplified the code and it seems length of URL is part of the problem. I tried to follow the forum suggestion and added the '-u' to the python call but it didn't affect the problem.

Here's the link to the forum post and I hope this is a better place to report what I think is a bug:
http://forum.arduino.cc/index.php?topic=222569.msg1626070#msg1626070

Here's the full output: first column is the URL length, second is execution time in ms, last column is amount of free memory in bytes. Execution times greater than 400ms and less than 3 sec usually indicate a successful Client.get() execution. When the execution time is less than 200ms the Client.get() failed to reach the server. I reported only the table up to 1000 chars of command. The program will continue with failed Client.get() until it runs out of memory with a URL of ~1,700 chars.

URL_length Execution_time Free_memory
52 2964 1839
65 908 1826
78 1117 1813
91 1123 1800
104 606 1787
117 1753 1774
130 1129 1761
143 412 1748
156 824 1735
169 527 1722
182 529 1709
195 841 1696
208 435 1683
221 415 1670
234 445 1657
247 530 1644
260 434 1631
273 1795 1618
286 10445 1605
299 10491 1592
312 10493 1579
325 10545 1566
338 10545 1553
351 10595 1540
364 10597 1527
377 10648 1514
390 10653 1501
403 10681 1488
416 10666 1475
429 10737 1462
442 10730 1449
455 10792 1436
468 877 1423
481 8896 1410
494 4455 1397
507 665 1384
520 675 1371
533 799 1358
546 695 1345
559 3095 1332
572 749 1319
585 726 1306
598 738 1293
611 789 1280
624 755 1267
637 767 1254
650 706 1241
663 792 1228
676 796 1215
689 835 1202
702 826 1189
715 834 1176
728 1289 1163
741 847 1150
754 957 1137
767 863 1124
780 864 1111
793 1474 1098
806 1499 1085
819 1474 1072
832 1537 1059
845 150 1046
858 151 1033
871 142 1020
884 140 1007
897 141 994
910 149 981
923 151 968
936 150 955
949 151 942
962 150 929
975 143 916
988 141 903
1001 151 890

Code:
PS: If you don't want to install the MemoryFree library, just comment the associated include and the freeMemory() call.

#include <Bridge.h>
#include <HttpClient.h>
#include <MemoryFree.h>

String url;

HttpClient client;

void setup() {
  pinMode(13, OUTPUT);
  digitalWrite(13, LOW);

  Bridge.begin();
  Serial.begin(9600);

  while(!Serial);
  Serial.println("Starting...");
  url="http://echo.jsontest.com/u?u=1234567890";
}

void loop() {
  url+="&u=1234567890";
  long start=millis();
  client.get(url);
  long delay=millis()-start;
  Serial.print(url.length());
  Serial.print("\t");
  Serial.print(String(delay));
  Serial.print("\t");
  Serial.println(freeMemory());
}
@roger77
Copy link
Author

roger77 commented Mar 16, 2014

Was anybody able to replicate this problem? Thanks

@agdl
Copy link
Member

agdl commented Jul 12, 2016

This issue was moved to arduino-libraries/Bridge#10

@agdl agdl closed this as completed Jul 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Library: Bridge The Bridge Arduino library
Projects
None yet
Development

No branches or pull requests

4 participants