njh / ruby-mqtt

Pure Ruby gem that implements the MQTT protocol, a lightweight protocol for publish/subscribe messaging.
http://www.rubydoc.info/gems/mqtt
MIT License
541 stars 135 forks source link

setting qos to 1 always sending the message #70

Closed tindaio closed 8 years ago

tindaio commented 8 years ago

I test a sample code and set QOS to 1. Why is the server is always sending the message to the subscribe client even the subscribe client already received the message and as I search https://github.com/njh/ruby-mqtt/pull/58 this should solve the problem because in MQTT specs the subscribe client should send PUBACK after receiving the message to tag that message is received. Did I missed something? Any tips?

sub.rb

require 'rubygems'
require 'mqtt'

MQTT::Client.connect('192.168.9.105') do |client|
  client.get_packet('test'=>1) do |packet|
    puts packet.inspect
  end
end

pub.rb

require 'rubygems'
require 'mqtt'

# Publish example
MQTT::Client.connect('192.168.9.105') do |c|
  c.publish('test', 'message 3', 0, 1)
end
alecdotninja commented 8 years ago

I am also having this issue.

@tindaio Were you ever able to solve the problem?

tindaio commented 8 years ago

@anarchocurious no solution yet. Using plain http get/post and json solution.

alecdotninja commented 8 years ago

@tindaio This issue has already been fixed on master.

Changing my Gemfile entry to gem 'mqtt', github: 'njh/ruby-mqtt' solves the problem for me.