MQTT (COMMUNICATION_ERROR): java.io.IOException: Connection reset by peer

OpenHAB2.5.9-1 (openHabian 1.6)
RPi 3B+

Hi,

This is my first tries in home automation. I’m trying to make it working,for 2 d3 days now. I must have reflased/reinstalled at leat 15 times in the last days, still with no success.

I have a problem with MQTT…

I am trying to configure as much as posisble via configurations files (I know… I like it the hard way!). Here is what I have configured:

I have installed mosquitto through openhabian-config, with a password
I have a static IP address on my RPi of 192.168.2.100

addons.cfg:

binding = mqtt, network

mqtt-things.things:
Bridge mqtt:broker:MQTTBroker “Mosquitto MQTT Broker” [
host=“192.168.2.100”,
secure=true,
username=“openhabian”,
password=“secretPwd”,
port=1883,
qos=0,
retain=false,
clientid=“openHAB-mqtt-bridge.things”,
keep_alive_time=30000,
reconnect_time=60000
]

Sonoffs.things:
Thing mqtt:topic:SonoffS31_FFFoyerLamp “FF Foyer Lamp” (mqtt:broker:MQTTBroker) @ “Sonoff S31” {
Channels:
Type string : reachable “Reachable” [ stateTopic=“tele/FF_Foyer_Lamp/LWT” ]
Type switch : switch “Power” [
stateTopic=“stat/FF_Foyer_Lamp/POWER”,
commandTopic=“cmnd/FF_Foyer_Lamp/power”,
ON=“ON”,
OFF=“OFF”
]

        Type number : rssi "WiFi Signal Strength"       [ stateTopic="tele/FF_Foyer_Lamp/STATE", transformationPattern="JSONPATH:$.Wifi.RSSI"]

        Type number : powerLoad "Instantaneous Power"   [ stateTopic="tele/FF_Foyer_Lamp/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Power"]

        Type number : voltage "Voltage"                 [ stateTopic="tele/FF_Foyer_Lamp/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Voltage"]

        Type number : energyTotal "Energy Total (kWh)"  [ stateTopic="tele/FF_Foyer_Lamp/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Total"]

}

MQTT server seems to be working just fine (from what I can understand), as I can see my sonoff switch in MQTT explorer (BTW… this is a must have . Awesome software), and I can interact with the switch throuogh MQTT explorer

My Problem…

i keep getting tht in the log viewer…
==> /var/log/openhab2/openhab.log <==

2020-10-17 20:31:24.673 [INFO ] [.reconnect.PeriodicReconnectStrategy] - Try to restore connection to ‘192.168.2.100’. Next attempt in 60000ms

2020-10-17 20:31:24.687 [INFO ] [.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to ‘192.168.2.100’ with clientid bf018795-5cd0-469c-80c1-3a023f133057

==> /var/log/openhab2/events.log <==

2020-10-17 20:31:24.679 [hingStatusInfoChangedEvent] - ‘mqtt:broker:368MosquittoBroker’ changed from OFFLINE (COMMUNICATION_ERROR): java.io.IOException: Connection reset by peer to OFFLINE

2020-10-17 20:31:24.747 [hingStatusInfoChangedEvent] - ‘mqtt:broker:368MosquittoBroker’ changed from OFFLINE to OFFLINE (COMMUNICATION_ERROR): java.io.IOException: Connection reset by peer

and it loops, bringing the same 2 messages over and over

help me please. This really seems like an awesome programm and I can’t wait to start playing with my new toy!

Some thoughts:

Is openHAB running on the same device as Mosquitto? Maybe try localhost instead of the IP address?

Are your username/password correct? Maybe consider not securing Mosquitto with a password - it might be complicating things.

Have you tried with secure=false as is the default (but keeping your username and password)?

What is 368MosquittoBroker? That’s not like any name you’ve defined. Does openHAB do this? Or did you previously try setting up a bridge with PaperUI, or through some other method?

This looks like a mouthful, and potentially a source of issues as it contains hyphens and periods. Try removing this parameter, or setting it to “”.

I don’t know the answer, but these are the first things I would look at and eliminate - essentially reduce the configuration of the bridge down to a host and port.

OMG… you saved my life. Thank you so much hafniumzinc.

I had already noticed the 368Mosquitto Broker thing and had fixed it (and I thought I had corrected the post… sorry).

It was the secure=false that did the trick.

now it is working. OpenHAB is connected to the broker, I can even control the switch from openHAB, the only problem that is left is that I can’t see to extract the individual values from the SENSOR json… I get that error:

[WARN ] [t.generic.ChannelStateTransformation] - Transformation service JSONPATH for pattern $.ENERGY.Voltage not found!

here is the thing definition:

Thing mqtt:topic:SF_POW_LAVEUSE “Laveuse” (mqtt:broker:MQTTBroker) @ “Sonoff POW” {
Channels:
Type string : reachable “Reachable” [ stateTopic=“tele/SF_POW_LAVEUSE/LWT” ]
Type switch : switch “Power” [
stateTopic=“stat/SF_POW_LAVEUSE/POWER”,
commandTopic=“cmnd/SF_POW_LAVEUSE/POWER”,
ON=“ON”,
OFF=“OFF”
]
Type number : rssi “WiFi Signal Strength” [ stateTopic=“tele/SF_POW_LAVEUSE/STATE”, transformationPattern=“JSONPATH:$.Wifi.RSSI”]
Type number : powerLoad “Instantaneous Power” [ stateTopic=“tele/SF_POW_LAVEUSE/SENSOR”, transformationPattern=“JSONPATH:$.ENERGY.Power”]
Type number : voltage “Voltage” [ stateTopic=“tele/SF_POW_LAVEUSE/SENSOR”, transformationPattern=“JSONPATH:$.ENERGY.Voltage”]
Type number : energyTotal “Energy Total (kWh)” [ stateTopic=“tele/SF_POW_LAVEUSE/SENSOR”, transformationPattern=“JSONPATH:$.ENERGY.Total”]
}

As mentionned the switch works just fine and in the log I see that the Sensor is returning all the values

2020-10-18 10:55:23.635 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Incoming payload ‘{“Time”:“2020-10-18T15:55:23”,“ENERGY”:{“TotalStartTime”:“2020-10-15T02:03:04”,“Total”:0.741,“Yesterday”:0.373,“Today”:0.030,“Period”:12,“Power”:80,“ApparentPower”:142,“ReactivePower”:118,“Factor”:0.56,“Voltage”:120,“Current”:1.187}}’ not supported by type ‘NumberValue’

Do I need to create a transformation? Sorry for this noob question… I’m really new in this and trying to learn from some example configuration I found.

Thanks a lot

Forget what I mentionned… I found the solution in the forum. I needed to install the jsonpath transformation (dough!).

Thanks a lot… evertything is now working. Many hours of fun to come!!!

Do you have the JSONPath transformation service installed?

EDIT: Simultaneous replies! Good work!