• Thanks - That looks like an issue with the SIM900 code then. The idea is that the send and recv functions in the JS code return a non-string value to signify an error (usually -1).

    You've made your own tweaked module haven't you? I think in the CIPSTART case, literally just removing the line throw new Error('CIPSTART failed.') will fix it - as then the socket data gets set to undefined, and next time Espruino tries to read or send data, the error will get reported back and the socket will get closed with everything freed.

    You could also look at where the handler for CONNECT OK is and add your own connect fail handler:

              at.registerLine(sckt + ', CONNECT FAIL', function() {
                at.unregisterLine(sckt + ', CONNECT FAIL');
                socks[sckt] = undefined;
                return "";
              });
    
About

Avatar for Gordon @Gordon started