Round Robin requestHandler


I have a function called requestHandler(request, response) that takes in a HTTP Request.

My question is, I know how to handle the request, I then know how to pass information to the device by using device.send("TEST_ROUTINE), tempstring), I then know how to look up some variables, I then know how to pass information back to the the agent using agent.send(“Okay”, tempString)…But then if I do a response.send(200, tempString), I then get the following error:

2016-02-29 20:19:25 UTC-5 [Agent] ERROR: the index ‘response’ does not exist
2016-02-29 20:19:25 UTC-5 [Agent] ERROR: at unknown:379

It seems like the response.send(200, tempString) only works within the requestHandler(request, response) function.

How can I do a round robin or complete check, in other words: Internet Request --> Agent --> Device --> Agent --> response?


This comes up quite often, so it’s explained a bit here: – to go straight to the code, search the page for the word “useful”.