Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By tomte76
#63553 Hi,

please find the attached code. If I run the function do_influx() attached to the ticker influx_ticker, as you can see in line 55, it runs every 60 seconds but the POST request will fail in HTTP_CLIENT, dns_gethostbyname with error -5. Which is ERR_CLSD. The connection seems to be closed.

If I run the function directly from loop(), as you can see in line 127, it works fine as expected. I dont understand, why it does not work as a ticker-function. Any hints on that? Thank you!
You do not have the required permissions to view the files attached to this post.
Last edited by tomte76 on Sat Mar 11, 2017 7:06 am, edited 1 time in total.
User avatar
By tomte76
#63554 here comes the output from "serial monitor"

[hostByName] request IP for: my-influx.some.domain
[hostByName] Host: my-influx.some.domain lookup error: -5!
[HTTP-Client] failed connect to my-influx.some.domain:8086
[HTTP-Client][returnError] error(-1): connection refused
[HTTP] GET... failed, error: connection refused
[HTTP-Client][end] tcp is closed
User avatar
By Pablo2048
#63556 Did You read the documentation for Ticker library?
It is currently not recommended to do blocking IO operations (network, serial, file) from Ticker callback functions. Instead, set a flag inside the ticker callback and check for that flag inside the loop function.
User avatar
By tomte76
#63586 I have to admit, I did not. To my defense I didn't even find it. I found the code in the library folder an read it. But there was no .md file and as I am not so familiar with ESP-Arduino (coming from Native SDK/RTOS) I didn't know about the /doc in the repos. Thank you for pointing. I'll read the whole documentation befor asking again ;)

Thank you!