I'd be very wary about comparing Espruino running on the ESP8266 and running on something else connected to an ESP8266 by AT commands.
drain is fired during HTTP handling when the send buffer is empty, not on a timeout: https://github.com/espruino/Espruino/blob/09412d6a02830abeee16f9582c8c4c7cf0ea4df9/libs/network/socketserver.c#L277
So it'll be very marginally faster if you keep the buffer full all the time.
I'd be pretty sure your issue is https://github.com/espruino/Espruino/blob/09412d6a02830abeee16f9582c8c4c7cf0ea4df9/libs/network/esp8266/network_esp8266.c#L763
the chunk size is 268 bytes, so it's only sending that amount each time - which probably results in a whole bunch of small TCP/IP packets being sent, rather than a few large ones.
Even so, 5 secs is particularly slow. You could take a look at req and res. In one of those there should be a field called dSnd which is the sent data buffer. You could check in an interval and see how quickly that's being emptied.
© Espruino, powered by microcosm.
Report a problem