Black Lives Matter - Action and Equality. ... Adafruit is open and shipping.
0

Adafruit_MQTT much faster than Adafruit_IO
Moderators: adafruit_support_bill, adafruit

Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
Please be positive and constructive with your questions and comments.

Adafruit_MQTT much faster than Adafruit_IO

by sellensr on Sun Jan 24, 2016 12:25 pm

Adafruit_IO_Client call to testFeed.send(count) takes about 8 seconds to return on my Huzzah 8266 and the new values appear in the feed around the end of that time. Calls to testFeed.receive() take about the same length of time to return.

Adafruit_MQTT_Client call to photocell.publish(x++) seems to take about 90 ms to return, same processor, 2 minutes later. The new values appear in the feed almost immediately.

Other than the obvious choice to use the MQTT library, is there something else to be learned here? Does the Adafruit_IO_Client have a built in slowdown, or is the server prioritizing MQTT calls? Or?

sellensr
 
Posts: 47
Joined: Tue Nov 06, 2012 9:41 pm

Re: Adafruit_MQTT much faster than Adafruit_IO

by clemens on Mon Jan 25, 2016 2:22 pm

Observed the same, seems that calls via the REST API are much more slower then via MQTT. I think it could not e.g. the header / protocol overhead only. Are both running on the same server? Is there a misconfiguration or something wrong? MQTT response times are really nice but REST is more or less unusable for repeated calls <1 or 2 minutes.

clemens
 
Posts: 41
Joined: Fri Jan 06, 2012 12:21 am

Re: Adafruit_MQTT much faster than Adafruit_IO

by sellensr on Mon Jan 25, 2016 4:30 pm

Both were going off to the same server at very close to the same time of day, with the same sort of data, and it was repeatable.

sellensr
 
Posts: 47
Joined: Tue Nov 06, 2012 9:41 pm

Re: Adafruit_MQTT much faster than Adafruit_IO

by clemens on Mon Jan 25, 2016 5:43 pm

Sorry was more a question to Adafruit! ;-) Perhaps Adafruit has two different server in the background that handle MQTT vs. REST calls.

clemens
 
Posts: 41
Joined: Fri Jan 06, 2012 12:21 am

Re: Adafruit_MQTT much faster than Adafruit_IO

by clemens on Mon Jan 25, 2016 6:13 pm

In addition: MQTT is faster because it uses a "keep alive connection" https://github.com/adafruit/Adafruit_IO_Arduino so it would be a good indicator ov equality / unequality in case we compare the initial / first MQTT call (setup connection and transmit values) and any REST call. In case you compare the second, tird connection and the connection was kept alive via MQTT you compare apples and oranges.

clemens
 
Posts: 41
Joined: Fri Jan 06, 2012 12:21 am

Re: Adafruit_MQTT much faster than Adafruit_IO

by jwcooper on Mon Jan 25, 2016 6:38 pm

We do have different processes and servers handling mqtt and REST. I would guess both should be similar speed, but MQTT doesn't need to setup/teardown the connection every request, which could be part of the difference on something like the ESP.

Something seems wrong if the API doesn't return for 8 seconds.

jwcooper
 
Posts: 679
Joined: Tue May 01, 2012 9:08 pm

Re: Adafruit_MQTT much faster than Adafruit_IO

by sellensr on Mon Jan 25, 2016 10:08 pm

@clemens I was doing some stuff with thingspeak at the same time, so same *service*, possibly different *servers* at AIO. The time to establish the MQTT connection initially seems to be about 1.2 seconds, unless it fails and waits...

@jwcooper I agree that 8 seconds seems wrong. The code is basically the 8266 sample with some additional stuff to do timing. Oddly, tonight it throws a 301 error, although it worked yesterday, and the MQTT version continues working fine. Thanks for any suggestions, however simply switching over to MQTT seems a good enough answer ;-)

Adafruit IO ESP8266 test!
Connecting to Signature . . . . . . WiFi connected
IP address: 192.168.0.110 Ready!
26419HTTP POST failed with error code: 301
Error writing value to esptestfeed!

resulted from this code fragment:

last = millis();
// Increment the count value and write it to the feed.
count += 1;
// To write a value just call the feed's send function and pass it the value.
// Send will create the feed on Adafruit IO if it doesn't already exist and
// then add the value to it. Send returns a boolean that's true if it works
// and false if it fails for some reason.
Serial.print(millis());
if (testFeed.send(count)) {
Serial.print(F(" Wrote value to esptestfeed: ")); Serial.print(count, DEC);
Serial.print(" took "); Serial.println(millis()-last);
}
else {
Serial.println(F("Error writing value to esptestfeed!"));
}

sellensr
 
Posts: 47
Joined: Tue Nov 06, 2012 9:41 pm

Re: Adafruit_MQTT much faster than Adafruit_IO

by clemens on Tue Jan 26, 2016 5:00 pm

Same here yesterday. I used the same sketch as hours before but got no feed update.

clemens
 
Posts: 41
Joined: Fri Jan 06, 2012 12:21 am

Re: Adafruit_MQTT much faster than Adafruit_IO

by sellensr on Wed Jan 27, 2016 10:30 am

Problem still there, and it looks like others have started talking about it... Beta is fun ;-) I hope we get similar issues later when my students are trying to implement so they can learn a little more about the real world.

sellensr
 
Posts: 47
Joined: Tue Nov 06, 2012 9:41 pm

Re: Adafruit_MQTT much faster than Adafruit_IO

by jwcooper on Fri Jan 29, 2016 2:14 pm

We setup new app servers and a new load balancer. This inadvertantly switched off insecure-http requests for the API. We've now re-enabled http-only for the API. Sorry about this downtime for your scripts and setups. We're hoping to have a lot of these infrastructure issues stablized soon.

jwcooper
 
Posts: 679
Joined: Tue May 01, 2012 9:08 pm

Re: Adafruit_MQTT much faster than Adafruit_IO

by sellensr on Fri Jan 29, 2016 2:20 pm

Thanks for being on top of it jw! I'll probably give it another try on the weekend and report back with some timing results if I find the time...

sellensr
 
Posts: 47
Joined: Tue Nov 06, 2012 9:41 pm

Re: Adafruit_MQTT much faster than Adafruit_IO

by sellensr on Sun Jan 31, 2016 11:29 am

Same code is now working again, still turning in response times of around 8 seconds. All seems well except the speed.

sellensr
 
Posts: 47
Joined: Tue Nov 06, 2012 9:41 pm

Please be positive and constructive with your questions and comments.