This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

mqtt with logic machine
#6
"not authorized" error means wrong username and/or password.

This works for me:
Code:
broker = 'mqtt.intingy.com'
port = 1883
username = 'entelechy_gateway'
password = 'wr6NOng8HzFC2KpB5cPoxXXgCSYBHXbGgRG9b3R39ok'
topic = 'entelechy/'
payload = 'mqtt_connection_test'

mqtt = require('mosquitto')
client = mqtt.new()

client.ON_CONNECT = function(status, rc, msg)
  if status then
    log('mqtt connected')
    client:publish(topic, tostring(payload))
  else
    log('mqtt connect failed ' .. tostring(msg))
    client:disconnect()
  end
end

client.ON_PUBLISH = function()
  log('publish ok')
  client:disconnect()
end

client:login_set(username, password)
status, rc, msg = client:connect(broker, port)

if status then
  client:loop_forever()
else
  log('connect failed: ' .. tostring(msg))
end
Reply


Messages In This Thread
mqtt with logic machine - by abby - 01.05.2024, 13:36
RE: mqtt with logic machine - by admin - 01.05.2024, 13:57
RE: mqtt with logic machine - by abby - 23.05.2024, 14:15
RE: mqtt with logic machine - by admin - 23.05.2024, 14:39
RE: mqtt with logic machine - by abby - 24.05.2024, 08:58
RE: mqtt with logic machine - by admin - 24.05.2024, 09:01
RE: mqtt with logic machine - by abby - 24.05.2024, 09:37
RE: mqtt with logic machine - by admin - 24.05.2024, 09:41
RE: mqtt with logic machine - by abby - 24.05.2024, 13:14
RE: mqtt with logic machine - by admin - 24.05.2024, 13:29
RE: mqtt with logic machine - by abby - 27.05.2024, 09:35
RE: mqtt with logic machine - by admin - 27.05.2024, 09:41
RE: mqtt with logic machine - by abby - 27.05.2024, 09:57
RE: mqtt with logic machine - by admin - 27.05.2024, 09:59
RE: mqtt with logic machine - by abby - 27.05.2024, 10:12
RE: mqtt with logic machine - by admin - 27.05.2024, 10:28
RE: mqtt with logic machine - by abby - 27.05.2024, 11:21
RE: mqtt with logic machine - by admin - 27.05.2024, 11:51
RE: mqtt with logic machine - by abby - 27.05.2024, 12:39
RE: mqtt with logic machine - by admin - 28.05.2024, 08:28
RE: mqtt with logic machine - by abby - 05.06.2024, 12:41
RE: mqtt with logic machine - by admin - 05.06.2024, 12:45
RE: mqtt with logic machine - by abby - 05.06.2024, 12:56
RE: mqtt with logic machine - by admin - 05.06.2024, 13:19
RE: mqtt with logic machine - by abby - 05.06.2024, 14:08
RE: mqtt with logic machine - by admin - 05.06.2024, 14:17
RE: mqtt with logic machine - by abby - 17.06.2024, 06:52

Forum Jump: