I have the following setup for testing my first project with ESP8266 and MQQT:
I have a Mosquito server installed on a Raspberry Pi - this will be the production server (once the project finishes)
I also have an old laptop with Mosquitto server installed - this is only for testing, especially to troubleshoot the problem I am describing here.
Finally, I have an ESP8266 running LUA code on it.
This is what is working so far:
I can publish messages from both the RPi and the laptop to themselves, to each other and to test.mosquitto.org.
I can subscribe to and receive messages on the RPi, on the laptop as well as on the ESP8266.
I can publish messages from the ESP8266 to test.mosquitto.org.
The only thing that's not working is to publish messages from the ESP8266 to any of my local Mosquitto installations, i.e. the RPi and the laptop.
In fact, the problem seems to be with the connection, as my code doesn't get past the point where it tries to connect to the server.
I find this strange, as normally stuff works on the local network and one might have more difficulty getting it right over the internet.
This is the code that connects perfectly to test.mosquitto.org and fails to connect locally:
--MQTTserver="192.168.1.138" -- when not commented out, this does not work
--MQTTserver="test.mosquitto.org" -- when not commented out, this works
m:connect(MQTTserver, 1883, 0, function(con2)
print("Connected.")
m:publish("viktak/test","Sensor online.",0,0, function(con2)
m:subscribe("viktak/test",0, function(con2)
end)
end)
end)
Any idea what might be the case? Can it be that the IP address should be specified in a different format? If yes, then what?
Thanks for any pointers!
http://diy.viktak.com