My code needs to load a web page multiple times. But after a few successful http calls it fails with "Uncaught Error: No free sockets".
I've removed my project-specific code to provide the simplest example of this error:
var tries=0;
function onInit() {
digitalWrite(B9,1); // enable on Pico Shim V2
Serial2.setup(115200, { rx: A3, tx : A2 });
var wifi = require("ESP8266WiFi_0v25").connect(Serial2, function(err) {
if (err) throw err;
wifi.reset(function(err) {
if (err) throw err;
console.log("Connecting to WiFi");
wifi.connect("SSID","password", function(err) {
if (err) throw err;
console.log("Connected");
setInterval(function () {
require("http").get("http://www.google.com", function(res) {
});
console.log("Attempt #" + ++tries);
}, 250);
});
});
});
}
onInit();
Google.com is simply an example; it fails with any website.
When running the code you'll see the number of attempts increment until it fails around #7 or #8. Apparently the require("http") call generates it. Oddly, changing the interval from 250 to something larger generates different errors but the end result is the same: the Espruino freezes.
I really need this to work as there is no workaround. Can anyone provide some guidance?
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
My code needs to load a web page multiple times. But after a few successful http calls it fails with "Uncaught Error: No free sockets".
I've removed my project-specific code to provide the simplest example of this error:
Google.com is simply an example; it fails with any website.
When running the code you'll see the number of attempts increment until it fails around #7 or #8. Apparently the require("http") call generates it. Oddly, changing the interval from 250 to something larger generates different errors but the end result is the same: the Espruino freezes.
I really need this to work as there is no workaround. Can anyone provide some guidance?
Thanks,
-Neil