Problems with publishMQTT after Update from OH2.4 to 2.5.0.M5

Tags: #<Tag:0x00007f616dcd7d48> #<Tag:0x00007f616dcd7be0> #<Tag:0x00007f616dcd7ac8>

Thank you for investing some time on this!

I tried the following:

  • Complete new installation of latest snapshot Build 1771.
  • Installed mqtt binding via PaperUI.
  • Imported my things-file, items-file and rules-file.

Result: The same as my original problem.

I even updated my Java version and deactivated my firewall. No change.

I have no idea what could be wrong and why it worked with 2.4.0 without any problems. :worried:

Plase install https://janessa.me/esh/org.openhab.binding.mqtt-debug.jar (instructions: option #2 from https://janessa.me/esh). The bundle number you are looking for is bundle:list -s | grep org.openhab.binding.mqtt (the one without further extension) and try again. It may be that you need a restart.

Hi Jan,

thanks, will give 2.5.0-RC1 a try once it becomes available.

Yet besides that error while manually triggering a reconnect, I’m facing an issue where the MQTT bridge apparently looses the connection to the broker. The bridge stays “online” and so does the MQTT client, yet no data is transmitted anymore. There is no related error message in the log, even when TRACE is enabled. I can see on the vacuum robot the connection is gone as all lights turn off on it while they stay on all the time when the connection to the MQTT bridge is established. The connection just drops after a few hours of OH being started. There is apparently no re-connect attempt by the MQTT bridge. I’m pretty sure this was working fine on 2.5.0-M4.

Thanks!

Thank you very much!
I will try it but it may take a few days. I will report!

Hello everybody,

i can confirm both bugs with current 2.5.0-M6: Bridge loose the connection to broker after couple of hours. There are no updates anymore. And try to send command leads in
[WARN] [nhab.binding.mqtt.action.MQTTActions] - MQTT publish to cmd failed!.
Additionally, binding reports
[WARN] [.incoming.MqttIncomingPublishService] - No publish flow registered for MqttStatefulPublish{stateless=MqttPublish{topic=wifistat, payload=55byte, qos=AT_MOST_ONCE, retain=false}, packetIdentifier=-1, dup=false, topicAlias=0, subscriptionIdentifiers=[]}

As far i can remember 2.5.0-M4 worked. Openhab runs on Raspberry.

Kind regards,

Alexander

Why does it lose connection? There must be something in the log. And which broker? And please use the debug-bundle.

Hi,

setup is described here. I installed debug version provided. As far more information is available, i’ll post it.

Kind regards,

Alexander

EDIT: Trying to send command leads in:

EDIT2: Some related information can be found here.

Hi Alexander,

is this resolving our issue?

Thanks!

Hello Thomas,

sadly no :frowning: I still get “MQTT publish to cmd failed!”. But it resolves the issue with state update.
And connection is recreated properly, if it got lost for some reason.
I think, we shall raise an issue in github.

Kind regards,

Alexander

Are you subscribed to the channel you are trying to post to?

If not: please create a thing/channel that subscribed to that topic and report back.

Hi @J-N-K. Thanks for replay :slight_smile:
I think, it may be a cause. I publish commands via:

val GetCommandJSON = [ String command |
  String::format("{\"command\":\"%s\",\"time\":%d,\"initiator\":\"localApp\"}", command, now.millis / 1000)
]

rule "RoombaCleanStartReceivedCommand"
when
  Item RoombaCleanStart received command ON
then
  val roomba = getActions("mqtt", "mqtt:broker:roomba")
  if(roomba !== null) {
    roomba.publishMQTT("cmd", GetCommandJSON.apply("start"))
  } else {
    logWarn("RoombaBroker", "Roomba broker returned no actions")
  }
end

I will setup HiveMQ CLI next days to be more precise where the error may be.

EDIT: Hello @J-N-K,
small update: I’ve created an command channel as

      Type string : command  "Command" [ commandTopic = "cmd" ]

as well item

String   RoombaSendCommand    "Roomba Command [%s]" { channel="mqtt:topic:roomba:state:command" }

and modified a rule to

rule "RoombaCleanStartReceivedCommand"
when
  Item RoombaCleanStart received command ON
then
  val cmd = String::format("{\"command\":\"start\",\"time\":%d,\"initiator\":\"localApp\"}", now.millis / 1000);
  RoombaSendCommand.sendCommand(cmd);
  logInfo("RoombaCleanStartReceivedCommand", cmd);
end

Now the situation is a little bit different: It happen still nothing, but there is no error message in log anymore. Trying to send something with publishMQTT, leads immediatly in

com.hivemq.client.mqtt.exceptions.MqttSessionExpiredException

I think, we have a bug in actions.

Kind regards,

Alexander

Hello everybody,

i set up debug environment and finally ended in

Server closed connection without DISCONNECT.

The error is thrown in MqttSession.java in hivemq.

Similar error is described here, excepting, that i get it, if call publishMQTT.

I’m not sure if, this is related.

Kind regards,

Alexander

Any news about that?
I’m facing same issue.

@J-N-K Is there a solution?
I’m having the same problem.

roomba.things:

Bridge mqtt:broker:roomba "MQTT Broker Roomba"  [ clientID="...", host="192.168.188.24", port=8883, secure=true,
                                                 username="...", password="..." ]
{
	Thing topic state "Roomba 980" {
		Channels:
			Type string : wifistat "WiFi"    [ stateTopic="wifistat" ]
			Type string : shadow   "Status"  [ stateTopic="$aws/things/.../shadow/#" ]
			Type string : cmd      "Command" [ commandTopic="cmd" ]
	}
}

roomba.items: (extract)

String   RoombaSendCommand    "Roomba Command [%s]" { channel="mqtt:topic:roomba:state:cmd" }

I’ve tried two different ways in my roomba.rules to send a command:

#1:

RoombaSendCommand.sendCommand(GetCommandJSON.apply("dock"))

#2:

val RuleRoombaActions = getActions("mqtt","mqtt:broker:roomba")
RuleRoombaActions.publishMQTT("cmd", GetCommandJSON.apply("dock"))

Log output for #1:

2020-04-20 11:36:52.362 [ome.event.ItemCommandEvent] - Item 'RoombaSendCommand' received command {command: 'dock', time: 1587375412, initiator: 'localApp'}
2020-04-20 11:36:52.368 [nt.ItemStatePredictedEvent] - RoombaSendCommand predicted to become {command: 'dock', time: 1587375412, initiator: 'localApp'}
2020-04-20 11:36:52.447 [vent.ItemStateChangedEvent] - RoombaSendCommand changed from NULL to {command: 'dock', time: 1587375412, initiator: 'localApp'}
2020-04-20 11:36:52.573 [hingStatusInfoChangedEvent] - 'mqtt:topic:roomba:state' changed from ONLINE to OFFLINE (COMMUNICATION_ERROR): Session expired as connection was closed.
2020-04-20 11:37:02.567 [INFO ] [.reconnect.PeriodicReconnectStrategy] - Try to restore connection to '192.168.188.24'. Next attempt in 60000ms
2020-04-20 11:37:02.571 [hingStatusInfoChangedEvent] - 'mqtt:broker:roomba' changed from ONLINE to OFFLINE
2020-04-20 11:37:02.581 [hingStatusInfoChangedEvent] - 'mqtt:topic:roomba:state' changed from OFFLINE (COMMUNICATION_ERROR): Session expired as connection was closed. to OFFLINE (BRIDGE_OFFLINE)
2020-04-20 11:37:02.574 [INFO ] [.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to '192.168.188.24' with clientid ...
2020-04-20 11:37:04.357 [hingStatusInfoChangedEvent] - 'mqtt:broker:roomba' changed from OFFLINE to ONLINE
2020-04-20 11:37:04.359 [hingStatusInfoChangedEvent] - 'mqtt:topic:roomba:state' changed from OFFLINE (BRIDGE_OFFLINE) to ONLINE

Log output for #2:

2020-04-20 11:45:35.531 [WARN ] [nhab.binding.mqtt.action.MQTTActions] - MQTT publish to cmd failed!
2020-04-20 11:45:45.527 [INFO ] [.reconnect.PeriodicReconnectStrategy] - Try to restore connection to '192.168.188.24'. Next attempt in 60000ms
2020-04-20 11:45:45.533 [hingStatusInfoChangedEvent] - 'mqtt:broker:roomba' changed from ONLINE to OFFLINE
2020-04-20 11:45:45.533 [INFO ] [.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to '192.168.188.24' with clientid ...
2020-04-20 11:45:45.544 [hingStatusInfoChangedEvent] - 'mqtt:topic:roomba:state' changed from ONLINE to OFFLINE (BRIDGE_OFFLINE)
2020-04-20 11:45:47.369 [hingStatusInfoChangedEvent] - 'mqtt:broker:roomba' changed from OFFLINE to ONLINE
2020-04-20 11:45:47.371 [hingStatusInfoChangedEvent] - 'mqtt:topic:roomba:state' changed from OFFLINE (BRIDGE_OFFLINE) to ONLINE

Do you have an idea?

Some basic information:

  • Openhabian installation, build 2.5.3
  • installed binding-mqtt - 2.5.3
  • tried with Moquette without success
  • uninstalled Moquette and installed Mosquitto using openhabian-config => also no success

Hi Patrick, I had a similar issue trying to connect via MQTT to an SPC Gateway (alarm system interface). I couldn’t get this method working as the MQTT broker on the system I was trying to connect to is only compatible with MQTT v3.1 clients, and as far as I can tell, OH > 2.5.0.M5 uses a later version of MQTT. I am trying to get it working using web sockets instead.

Check what MQTT client version is supported by the broker on the Roomba.

1 Like

We still have a v3 client. I don‘t have these problems with a Mosquitto broker, so I can‘t fix problems I can‘t see.

Hi Jan,

How would I use the v3 client - I’m now on OH 2.5.4 release?

The openHAB core supports v3 and v5 clients, but the MQTT binding always uses the v3 client, there is now way to selevt the v5 client at the moment.

I understand your argumentation, but there are 3-4 more people (see iRobot 9xx on openHAB) with this problem. And as I have read, the same configuration is working with OH 2.5M4 (and before).
So something has changed with the 2.5 release.

Please let me know how I can support you to identify the problem.

Thanks for your advice.
There are already some solutions (Phyton, Java, Rest API) but I don’t want to have an additional program/script/… when the Roomba is using MQTT and OH supports this.