Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Binary Support in Last Will and Testament #14

Open
reedleoneil opened this issue Dec 26, 2019 · 0 comments
Open

Binary Support in Last Will and Testament #14

reedleoneil opened this issue Dec 26, 2019 · 0 comments

Comments

@reedleoneil
Copy link

I'm having an error when connecting to the broker if I have a binary LWT.

../paho-mqtt-1.0.12/lib/paho_mqtt/client.rb:116:in `connect'
../paho-mqtt-1.0.12/lib/paho_mqtt/connection_helper.rb:136:in `send_connect'
../paho-mqtt-1.0.12/lib/paho_mqtt/sender.rb:34:in `send_packet'
../paho-mqtt-1.0.12/lib/paho_mqtt/sender.rb:41:in `rescue in send_packet': PahoMqtt::WritingException

Here is my sample code:

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.

Thanks in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant