tarantool / mqtt

Tarantool MQTT client

Home Page:tarantool.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Publish always returns true (even if the server is unreachable)

vvzvlad opened this issue · comments

Суть: если выполнить mqtt_object:publish при недостижимом сервере (например, остановленном или отключенным от сети), первые несколько минут он все равно вернет true. В аналогичном случае mosquitto_pub некоторое время висит, а потом говорит "Error: Operation timed out"

Как воспроизвести:

local mqtt = require 'mqtt'
mqtt.wb = mqtt.new("id", true)
mqtt.wb:connect({host="host",port=1883,keepalive=60,log_mask=mqtt.LOG_ALL})
--отключаем/останавливаем mqtt-сервер--
local status = mqtt.wb:publish("/topic", "value", mqtt.QOS_1, mqtt.NON_RETAIN)
print(status) --Возвращает "true"

Hi, thank you for your bug report. Care to send us a pull request?

The same issue is here. This doesn't work as expected:
local status = connection:publish(topic, data, mqtt.QOS_1, mqtt.NON_RETAIN) if not status and not connection.connect then connection:reconnect() end

@kostja I do not know how to fix this, so I can not do pull request

assigned to @romankhabibov

@vvzvlad @cyanide-burnout can't reproduce. Can you say OS?

@vvzvlad can you retest this with the latest master?

Thanks!

Debian 8 x64

OS: Darwin MBP.local 17.5.0 Darwin Kernel Version 17.5.0: Fri Apr 13 19:32:32 PDT 2018; root:xnu-4570.51.2~1/RELEASE_X86_64 x86_64

Found new bug:

send status:	true	5
send status:	true	6
send status:	true	7
send status:	true	8
MQTT disconnect  ///Stop broker
send status:	false	The client is not currently connected.
send status:	false	The client is not currently connected.
...
send status:	false	The client is not currently connected.
send status:	false	The client is not currently connected.
send status:	true	29 ///Fake true 
send status:	true	30
send status:	true	31
....
send status:	true	39
MQTT connect   ///Real start broker
send status:	true	40
send status:	true	41

Test code:

#!/usr/bin/env tarantool
local mqtt = require 'mqtt'
local fiber = require 'fiber'

local function mqtt_disconnect_callback()
   print("MQTT disconnect")
end
local function mqtt_connect_callback()
   print("MQTT connect")
end

mqtt.wb = mqtt.new("test_id", true)
print(mqtt.wb:connect({}))
mqtt.wb:on_disconnect(mqtt_disconnect_callback)
mqtt.wb:on_connect(mqtt_connect_callback)

local function test()
   while true do
      print("send status:", mqtt.wb:publish("/topic", "", mqtt.QOS_1, mqtt.NON_RETAIN))
      fiber.sleep(1)
   end
end
fiber.create(test)

This is an libmosquito issue, and also this behaviour definitely changed after fixes/patches.

So I close this, I guess, that we have to create a new issue, if this will be repeated.