Comments (13)
We've been fighting this for days. The "Publish failed" message is in the example code itself.
The real error returned is -30. This corresponds to The client state is not idle when request is being made
I think we have it fixed. It has to do with a Yield function in AWS_IOT.cpp
We have reduced the yield time to 5ms and the TaksDelay to 550; Try that.
void aws_iot_task(void *param) {
IoT_Error_t rc = SUCCESS;
while(1)
{
//Max time the yield function will wait for read messages
rc = aws_iot_mqtt_yield(&client, 5);
if(NETWORK_ATTEMPTING_RECONNECT == rc)
{
// If the client is attempting to reconnect we will skip the rest of the loop.
continue;
}
vTaskDelay(550/ portTICK_RATE_MS);
}
}
from hornbill-examples.
And to elaborate on why you should change the aws_iot_task to use 5ms timeout and 550 task delay. Previously the settings were 200ms timeout and 1 second delay. Let's put that in perspective. That means that 200/1200 of the time (1/6th of the time) the library was waiting for MQTT traffic in the call to aws_iot_mqtt_yield. Because it is running in a separate thread it could do this behind your back. So, when you try to publish you have a 1 out of 6 chance of the library actually being in the wait state inside of aws_iot_mqtt_yield. Changing this timeout to 5ms but doing it about twice as often yields a 5/555 chance (1/111) which is MUCH better odds. You don't need to spend forever in each call to aws_iot_mqtt_yield. The underlying networking stack will queue frames for you and unless you've got a lot of subscribed messages you aren't going to stack them up. If you do have a lot of subscribed messages coming in then just lower the wait time and the delay time. There's no reason to wait more than 1-2 milliseconds if no message is pending to be received. So, 1ms wait and like 100ms delay would be fine if you don't think you'd get more than 10 MQTT messages per second. At any rate, you can calculate your chances of this library killing your publishes as (yieldtime)/(yieldtime + delaytime).
A potentially better solution is to move the call to aws_iot_mqtt_yield to your sketch's loop function. This could be done by exposing a method from the AWS_IOT class that you call in loop. I understand why the author didn't do this. It would make it more complicated to use and people would have to actually add the call to loop. But, it then yields a basically 0% chance of a publish failure due to client state not idle.
And that's all I have to say about that. ;)
from hornbill-examples.
@paulmand3I look at #9
You can go to AWS_IOT.cpp file and remove
#include "aws_iot_certificates.c"
and add a file in Arduino sketch say AWS_certs.h
in that file, you can copy define all certs with
extern extern const char aws_root_ca_pem[] = {""}
extern const char certificate_pem_crt[] = {""}
extern const char private_pem_key[] = {""}
and your certs in that. Atleast that worked for me.
from hornbill-examples.
I'm experiencing the same problem: every n-th publish request fails. Can you pls track and resolve this?
Thx.
Ivan
from hornbill-examples.
Any progress on this topic?
from hornbill-examples.
Look at the error code and compare it to aws_iot_error.h
. This will give you some info
from hornbill-examples.
Does anyone know how to correctly include the certificates in the .ino file?
I have tried adding them one by one after this line "char rcvdPayload[512];" but I keep getting this error > "E (2195740) aws_iot: failed! mbedtls_x509_crt_parse returned -0x2180 while parsing root cert
E (2195747) AWS_IOT: Error(-19) connecting to apvo8rqcqjnk3.iot.us-east-2.amazonaws.com:8883,"
Any help will be appreciated.
from hornbill-examples.
Check this tutorial.
http://exploreembedded.com/wiki/AWS_IOT_with_Arduino_ESP32
Include the certificates in this file. Do not forget to add '\n' at the end of each line except for the last line.
https://github.com/ExploreEmbedded/Hornbill-Examples/blob/master/arduino-esp32/AWS_IOT/src/aws_iot_certficates.c
from hornbill-examples.
So I can't include different certificates per project? I have to put them in the library itself?
from hornbill-examples.
Hi, Also get this every 6th publish is failing.
Connected to wifi
Connected to AWS
Subscribe Successfull
return -30
Publish failed
Publish Message:Hello from hornbill ESP32 : 1
Received Message:Hello from hornbill ESP32 : 1
Publish Message:Hello from hornbill ESP32 : 2
Received Message:Hello from hornbill ESP32 : 2
Publish Message:Hello from hornbill ESP32 : 3
Received Message:Hello from hornbill ESP32 : 3
Publish Message:Hello from hornbill ESP32 : 4
Received Message:Hello from hornbill ESP32 : 4
Publish Message:Hello from hornbill ESP32 : 5
Received Message:Hello from hornbill ESP32 : 5
return -30
Publish failed
Publish Message:Hello from hornbill ESP32 : 7
Received Message:Hello from hornbill ESP32 : 7
Publish Message:Hello from hornbill ESP32 : 8
Received Message:Hello from hornbill ESP32 : 8
Publish Message:Hello from hornbill ESP32 : 9
Received Message:Hello from hornbill ESP32 : 9
Publish Message:Hello from hornbill ESP32 : 10
Received Message:Hello from hornbill ESP32 : 10
Publish Message:Hello from hornbill ESP32 : 11
Received Message:Hello from hornbill ESP32 : 11
return -30
Publish failed
Publish Message:Hello from hornbill ESP32 : 13
Received Message:Hello from hornbill ESP32 : 13
according to aws_iot_error.h it is MQTT_CLIENT_NOT_IDLE_ERROR = -30
So just one question. Would I be able to publish a stream of ADXL345 data very fast to AWS IoT in that case?
from hornbill-examples.
void aws_iot_task(void *param) {
IoT_Error_t rc = SUCCESS;
while(1) { //Max time the yield function will wait for read messages rc = aws_iot_mqtt_yield(&client, 5); if(NETWORK_ATTEMPTING_RECONNECT == rc) { // If the client is attempting to reconnect we will skip the rest of the loop. continue; } vTaskDelay(550/ portTICK_RATE_MS); }
}
I changed in AWS_IOT.cpp, I don't receive Public fail anymore
from hornbill-examples.
Thanks for this fix. Saved a bunch of code trying to deal with the occasional failure.
from hornbill-examples.
Same issue, worked like a charm ! Thanks !
from hornbill-examples.
Related Issues (20)
- running out of memory when doing the TLS handshake
- AWS ALPN protocol - not seeing it referenced here in the repo...
- Error parsing root-ca HOT 3
- failed! mbedtls_net_connect returned -0x44 HOT 1
- Wrting a Book using hornbill
- Cannot connect to AWS in the loop.
- # Its showing that the specified zip/folder does not contain a valid library. HOT 1
- AWS_IOT: Error(-28) HOT 1
- Publishing message without internet access
- Unable to connect due to certificate error
- Not receiving MQTT messages when subscribe is done using a non const char HOT 1
- fatal error: mbedtls/config.h: No such file or directory HOT 5
- Feature of Hornbill
- AWS OTA (Over The Air) Update HOT 1
- large payloads do not get returned HOT 1
- sending large payload truncates the string - TX buffer size? HOT 1
- Stops Publishing
- esp8266
- How can I send a file saved in SPIFFS in esp32?
- AWS_iot.h file is not found in directory in current version
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hornbill-examples.