I followed the really good tutorial from here and I'm able to get a basic nodejs-websocket scenario working with the Tessel as a client and a custom NodeJS app running on my Macbook as the server and just sending a single text message every minute or so.
However, when I use my socket server application to relay data from the Leap Motion websocket server, which is a pretty big JSON object around thirty times per second, the Tessel can't keep up. (I'm using
connection.sendText(payload.toString()) and not a binary/stream scenario.) It keeps up for a short while, but soon bogs down and the data starts coming in brief waves. It then stalls completely and the client closes the connection with an error code of 1002. As a test, I ran the same client application from another computer and it kept up fine, so I'm assuming I'm either bumping up against a processing power ceiling of the Tessel, or something related to the nodejs-websocket implementation on the Tessel.
I'm pretty uneducated when it comes to sockets and the nodejs-websocket module. What am I running up against in the Tessel scenario, and is there a way to fix it? Do I need to look at streams, or is there a way to empower the buffering to even things out?
UPDATE: I dramatically reduced the size of data I was sending over the socket to Tessel (the 'frames' object from Leap Motion is pretty big), and reduced the number of .sendText() calls from up to 200 times per second down to 4 times per second, and it dramatically improved things, in that it doesn't completely freeze up and stop. I do see it bog down every ten seconds or so, then race to catch up with what looks like a buffer of six or eight calls that it missed. Would love to ensure an even flow somehow.