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 lib references? enable TLS for use with AWS
#15
(26.11.2018, 10:29)admin Wrote: Post whole code that you're using.

Code:
mqtt = require("mosquitto")
client = mqtt.new()

client.ON_CONNECT = function()
       client:publish("world", "hello")
       local qos = 0
 local retain = false

 local mid = client:publish("/Office/PM/PM710/Voltage", string.format("%.2f", grp.getvalue('7/0/0')), qos, retain)
 local mid = client:publish("/Office/MT300/Temp", string.format("%.2f",grp.getvalue('7/0/2')), qos, retain)
 local mid = client:publish("/Office/PAC3200/Voltage/Fase1", string.format("%.2f",grp.getvalue('7/0/3')), qos, retain)
 local mid = client:publish("/Office/PAC3200/Corriente/Fase1", string.format("%.2f",grp.getvalue('7/0/10')), qos, retain)
 local mid = client:publish("/Office/PAC3200/Corriente/Fase2", string.format("%.2f",grp.getvalue('7/0/11')), qos, retain)  
 local mid = client:publish("/Office/PAC3200/Corriente/Fase3", string.format("%.2f",grp.getvalue('7/0/12')), qos, retain)  
 local mid = client:publish("/Office/PAC3200/PATotal", string.format("%.2f",grp.getvalue('7/0/13')), qos, retain)  
 
end

client.ON_PUBLISH = function()
client:disconnect()
end

broker = 'url'
cafile = '/home/ftp/home/ftp/CA-Root.pem'
certfile = '/home/ftp/home/ftp/8f8253e1f4-certificate.pem.crt'
keyfile = '/home/ftp/home/ftp/8f8253e1f4-private.pem.key'
client:tls_set(cafile, nil, certfile, keyfile)
--client:login_set("undefine",jwt) --Testing GCS
client:connect(broker, 8883)
client:loop_forever()

This is the code is now working ok with a Mosquitto install in a different server but with no security.....

Should be done differently?

Thanks for all the help so far.  Big Grin
Reply


Messages In This Thread
RE: MQTT lib references? enable TLS for use with AWS - by juanpalf - 26.11.2018, 14:06

Forum Jump: