require 'paho-mqtt'
require 'msgpacker'
require 'json'
last_will = {
:id => 1,
:data => "test data"
}
mqtt_settings = {
:host => 'localhost',
:port => 1883,
:persistent => true,
:reconnect_limit => 3,
:reconnect_delay => 60,
:will_topic => 'test_topic',
:will_payload => last_will.to_msgpack, # will not work
#:will_payload => File.binread('test_file', 32, 0), # will not work
#:will_payload => last_will.to_json, # will work
:will_qos => 2,
:will_retain => false
}
mqtt_client = PahoMqtt::Client.new(mqtt_settings)
mqtt_client.connect
loop do
mqtt_client.loop_read
mqtt_client.loop_write
end
I am using msgpacker to serialize my data into binary for the :will_topic but I am having error. I tried to read a binary file for the :will_topic but it also have the same error.
I'm having an error when connecting to the broker if I have a binary LWT.
Here is my sample code:
I am using msgpacker to serialize my data into binary for the :will_topic but I am having error. I tried to read a binary file for the :will_topic but it also have the same error.
Thanks in advance!