I've been working on a script that reads data from each of my modules and POSTs them up to a server. I have had some issues with serializing a JS object to the correct form parameters for the post with
http.request (it only ever sent the first key value pair as form params) so I started using the needle library, which works great.
However, when I leave the Tessel running this script, it eventually (after an hour or so, it seems) hits this error:
Error: ENOENT: Cannot open another socket. Eventually the log looks like this, as well, but the program continues to run:
Error: ENOENT Cannot close socket 1 Got: err-5
Error: Socket closed.
Error: ENOENT: Cannot open another socket.
(It has halted a few times with a short Lua stack trace, but I didn't save any of those, so I don't have one to share.)
I know that Node has its own limit of open sockets, which is typically 5 (and could be different here? I don't know how the Tessel implements it), and I learned from https://forums.tessel.io/t/tessel-stops-running-after-15-minutes/859/47 that there's some issues at the hardware level with having more open. I'd thought that Node would treat the HTTP requests like a queue, and only perform 5 at a time.
I could try reducing the number of POSTs I do every 60 seconds (4 of them) by consolidating into one endpoint, and changing the server it is posting to, but I'm not sure whether that will increase the stability of the program.
Any thoughts? I'd like to get to the point where it just runs 24/7 without any fuss, POSTing every 60 seconds.