not able to connect to test.mosquitto.org

Ankit jhunjhunwala picture Ankit jhunjhunwala · Jan 5, 2016 · Viewed 10.4k times · Source

I am working on esp8266 and trying to connect to test.mosquitto.org. here is what I got from net

m = mqtt.Client("clientid", 60, "user", "password")
m:on("connect", function(con) print ("connected") end)
m:on("offline", function(con) print ("offline") end)
m:on("message", function(conn, topic, data) 
  print(topic .. ":" ) 
  if data ~= nil then
    print(data)
  end
end)

m:connect("http://test.mosquitto.org/", 1883, 0, function(conn) print("connected") end)
m:subscribe("/topic",0, function(conn) print("subscribe success") end)
m:publish("/topic","hello",0,0, function(conn) print("sent") end)
m:close();

I am not sure from where to get clientId ,user and pass,

here what I am getting : DNS retry 1! DNS retry 2! DNS retry 3! DNS retry 4! DNS Fail!

Answer

ProgrammerV5 picture ProgrammerV5 · Jan 5, 2016

Try with the IP instead of the name:

m:connect("85.119.83.194", 1883, 0, function(conn) print("connected") end)

if that works that means that you are having a problem resolving the name of the website (for whatever reason).