ruby - setting qos to 1 always sending the message -
i test sample code , set qos 1. why server sending message subscribe client subscribe client received message , search https://github.com/njh/ruby-mqtt/pull/58 should solve problem because in mqtt specs subscribe client should send puback after receiving message confirm message received. did missed something? tips?
sub.rb
require 'rubygems' require 'mqtt' mqtt::client.connect('192.168.9.105') |client| client.get_packet('test'=>1) |packet| puts packet.inspect end end
pub.rb
require 'rubygems' require 'mqtt' # publish example mqtt::client.connect('192.168.9.105') |c| c.publish('test', 'message 3', 0, 1) end
because mqtt specifications qos 1 states message delivered at least once, may delivered more 1 time. (eg. puback timeout, network issues)
quoting specs link:
although tcp guarantees delivery of packets, there scenarios mqtt message may not received. in case of mqtt messages expect response (qos >0 publish, pubrel, subscribe, unsubscribe), if response not received within time period, sender may retry delivery. sender should set dup flag on message.
this can maybe bug in ruby client implementation. broker compliant specs , re-delivers message.
if need message delivered once try qos 2.
Comments
Post a Comment