Hi @Gordon and others,
I've used Espruino Pico with ESP8266 on it. My device is trying to connect to the internet the similar way that the Amazon Echo or Google Home connects.
I collect the WiFi credentials using a web form that is served from the HTTP server that runs on Espruino Pico,
After collecting the WiFi credentials and storing them in the ROM, i close the server, connect to the internet and then finally connect to my MQTT broker that runs on Digital Ocean.
var client = require("MQTT").create(server, options /*optional*/);
.... // some code
apServer.close()
.... // some code
client.connect();
I get the error message from MQTT client saying that the connection is closed.
in function called from system
Uncaught Error: This socket is closed.
at line 1 col 56
...ite(b(a.DISCONNECT<<4)+'\0'),this.client.end(),this.client=!...
^
in function "disconnect" called from line 1 col 52
c.ctimo=void 0,c.emit('disconnected'),c.disconnect();
^
But the MQTT broker is running fine and i get to see that MQTT client could reach the broker server. Instead of MQTT client call, if i make the following call, it works,
I believe that there is something happening only after i run the HTTP server and close. Because if i retrieve the WiFi credentials from the memory instead of running the HTTP server and I'm able to connect to the MQTT broker successfully.
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.
Hi @Gordon and others,
I've used Espruino Pico with ESP8266 on it. My device is trying to connect to the internet the similar way that the Amazon Echo or Google Home connects.
I collect the WiFi credentials using a web form that is served from the HTTP server that runs on Espruino Pico,
After collecting the WiFi credentials and storing them in the ROM, i close the server, connect to the internet and then finally connect to my MQTT broker that runs on Digital Ocean.
I get the error message from MQTT client saying that the connection is closed.
But the MQTT broker is running fine and i get to see that MQTT client could reach the broker server. Instead of MQTT client call, if i make the following call, it works,
I believe that there is something happening only after i run the HTTP server and close. Because if i retrieve the WiFi credentials from the memory instead of running the HTTP server and I'm able to connect to the MQTT broker successfully.
Please help me.. thanks.