-
Hi,
I'm trying to use MQTT on a ESP8266 (Flash map 1MB:512/512, manuf 0xc8 chip 0x4014) and always returns same error:
1526108440: New connection from 192.168.10.44 on port 1883. 1526108440: New client connected from 192.168.10.44 as 4e8422275dd0 (c1, k60). 1526108440: Socket error on client 4e8422275dd0, disconnecting.
It's only a simple connection test code like this:
var wifi = require("Wifi"); var mqtt = require("MQTT").create("192.168.10.43", { keep_alive: 60, clean_session: true }); wifi.connect("MyWifi", {password: "MyPassword"},function(err){ if (!err) { const info = wifi.getIP(); console.log('connected? err=', err, 'info=', info); mqtt.connect(); } else { console.log('error: ',err); } }); wifi.stopAP(); mqtt.on("connected", function(){ console.log("connected"); }); mqtt.on("disconnected", function(){ console.log("disconnected"); });
The output is always the same:
> ____ _ | __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |____|___| _|_| |___|_|_|_|___| |_| espruino.com 1v97 (c) 2018 G.Williams Espruino is Open Source. Our work is supported only by sales of official boards and donations: http://espruino.com/Donate Flash map 1MB:512/512, manuf 0xc8 chip 0x4014 >connected? err= null info= { "ip": "192.168.10.44", "netmask": "255.255.255.0", "gw": "192.168.10.1", "mac": "5c:cf:7f:f1:bd:25" } connected > =undefined disconnected disconnected >
I try a lot of configurations and I don't know how to continue:
- Mosquitto server's: 1.4.14, 1.4.15, "test.mosquitto.org",...etc
- Test on different ESP8266 boards.
- Using module "MQTT" and "TinyMQTT".
- Move "mqtt.connect()" line inside "wifi.connect" callback
Try using connect directly:
var mqtt = require("MQTT").connect({ host: "192.168.10.43", });
Run mosquitto server in verbose mode "mosquitto -v":
1526109123: New connection from 192.168.10.44 on port 1883. 1526109123: New client connected from 192.168.10.44 as 3fefc4344328 (c1, k60). 1526109123: Sending CONNACK to 3fefc4344328 (0, 0) 1526109123: Socket error on client 3fefc4344328, disconnecting.
Mosquitto server is up and runnig with anonymous access acepted. I'm using this server with other esp8266 boards running native C code and goes good, so I think that is no problem with the server.
If someone can help me with this problem, I would be enormously grateful.
Thank you
- Mosquitto server's: 1.4.14, 1.4.15, "test.mosquitto.org",...etc
Thank you very much @Gordon. I delete flash and upgrade to 1v97.98 and works great!!!
I saw new versions at http://www.espruino.com/binaries/travis/master/ for example release 1v97.100. This versions are the last development versions?. Are the same as github repository "master" branch?
Thank you.
Best regards,
Juanillo