Http.onrequest invocation delay

Can anyone tell me why when I use my web browser to send an http request to my agent, it takes several seconds before the request is received? But if I repost the request, it responds immediately.

Here is my agent code:

function requestHandler(request, response) { server.log("received request"); try { response.send(200, "OK"); } catch (ex) { response.send(500, "Internal Server Error: " + ex); } } // register the HTTP handler http.onrequest(requestHandler);

The code looks fine. When you say it’s fast second time, when does it become slow again? Wondering if there’s slow DNS here, for example.

The behavior I see is that when I invoke the request, the browser status says: ‘waiting for agent.electric.imp’. If during that time, I place the cursor in the browser field where one enters the url and then press enter, the post is received by my agent straight away. The next time I try to post, I get the same slow behavior.

Sometimes the browser times out, but if I click the error dialog’s ‘Reload’ button, the request is received by my agent immediately.

I have seen the same behavior using Chrome at home and using IE on a different network at my office.

I have also tried using the sample agent that toggles an LED on and off. (This was actually the first thing I did with my IMP to see how things are put together.) It behaved as one would expect when I first tried it; requests were received almost instantaneously. But now, the LED agent exhibits the same symptoms.

The world will not quit turning if I can find no solution for this, but I would appreciate any insight you can provide.


Can you PM me with a device ID and I can look in the logs?

My agent is responding normally now. Thanks for your help.