i’m a real beginner with coding and the electric imp so please be gentle,
i have 3 imps/april, i’m trying to send 2 integers (sensor states) from 1 imp to the other 2,
i can send from one imp to another , but i am stuck trying to send to multiple imps,
also what does ‘429: rate limit exceeded’ mean?, how do i recover from it, and how do i avoid it, (pretty much what am i doing wrong?.. beside everything… >.<
I’m assuming you’re sending messages between imps with HTTP requests. If you want to send a message from 1 imp to two other imps, you simply need to do 2 HTTP requests instead of 1 (1 request to each of the imp’s agent url).
“429: rate limit exceeded” means you are making too many HTTP requests to an agent too quickly. You can make about 10 requests per second before you get that message, so you likely want to make sure you’re blasting messages quicker than that.
i’ve tried that previously and no luck, i just tried it agian and no luck as well,
i don’t know how the son’s agent code will breakdown that the accstate integer will correspond with the accstate call, and the same for the flexstate,
when i combine the call, i get a ‘404 no http handler’, i assume this is becuase the son’s agent req.query code no longer suited to the new call format…
this is the son’s current agent code:
`server.log(“agent active”);
local ledstate = 0;
local RGBstate = 0;
function httpHandler(req, resp) {
server.log(“igota reqest”);
if ("accstate" in req.query) {
RGBstate = req.query.accstate.tointeger();
}
if ("flexstate" in req.query) {
ledstate = req.query.flexstate.tointeger();
}
server.log("RBGstate: " + RGBstate + " ledstate: " + ledstate);
local sensorstate = [RGBstate, ledstate];
device.send("ledOn", sensorstate )
resp.send(200, "son says hi");
}
http.onrequest(httpHandler);`
how can i get the son’s req.query to read the new call format??
i would really like to package the call better as i would like to add more imps, and it’s just getting too much and keep running into the '429 rate limit exceeded problem
any advice is appreciated…
I wrapped you code in Code tags (the “C” icon above the text entry box).
The only reason you get 404 messages is if your agent does not have a request handler, or you have mis-typed the agent URL you are making a request to - are you 100% positive you typed the Agent URL correctly?
The easiest way to test requests made with Query parameters is to browse to the Agent URL you are making a request to in this case, SonAgentURL and DaughterAgentURL). You can easily do this by going to their agent and clicking on the agent url. Once you have that URL, you shoudl be able the parameters you want to the end of it :