Skip to content

Binary Support in Last Will and Testament #14

Description

@reedleoneil

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!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions