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

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.