I’m looking forward to release 38 where the imp will be able to detect when the TCP send buffer is full. I have a question about current release 36 behaviour.
If my device is set to use RETURN_ON_ERROR and it tries to send when the TCP buffer is full, the docs say that the imp disconnects and invokes server.restart(). In that scenario, which reason code will hardware.wakereason() report upon restart? Is it an out of memory event?
The send attempt will continue until the specified send timeout is reached (though the send will block). If the timeout has been reached and there’s still no buffer space to queue the data you’re trying to send, the send will fail.
A failed send causes a disconnection, and SEND_ERROR_TIMEOUT will be returned from the server.log or agent.send that failed. See https://developer.electricimp.com/api/agent/send
I can’t see anywhere in the docs that say server.restart() is called. This does not happen, and would be an awful idea.
Sorry, you’re right. I misread/misinterpreted imp.setsendbuffersize()
The new size of the buffer will be preserved across a Squirrel reload provided no reconnection takes place — for example, if a send policy of RETURN_ON_ERROR is in place, the imp is disconnected and calls server.restart() .