Agent.send execution

When we call agent.send, does it return immediately after that data is sent to the server or does it return after the corresponding device.on callback is finished executing?

Im wondering if processing on the server side would keep my imp from going to sleep longer than I want.

By default, it returns as soon as the data is queued for sending on the imp. The other available option is to return once the server has acked (at the TCP level) the reception of the message (which will almost always be just one round-trip-time later). In either case, it doesn’t wait for the agent handler to run.