Struggling to connect to openmqtt lilygo_rtl33

Hi I’ve installed openmqtt on lilygo_rtl433, however I’m getting issues connecting to MQTT.

Here’s my webui settings:

And here’s mqtt explorer equivalent:
image

i can execute commands like this on linux box with no issues:
mosquitto_pub -h ‘192.168.3.104’ -t ‘W/e45f01b330f7/test’ -m ‘1’

Console output looks like this:

W: MQTT connection...
W: failure_number_mqtt: 1
W: failed, rc=-4
W: MQTT connection...
W: failure_number_mqtt: 2
W: failed, rc=-4
rtl_433_ESP(7): Average RSSI Signal -114 dbm, adjusted RSSI Threshold -105, samples 50000
W: MQTT connection...
W: failure_number_mqtt: 3

Any tips (I have tweaked source code however I’ve only edited pub_custom_topic method and tbf i have if statement that should mean my code shouldn’t run atm.

EDIT:
It has something to do with victron’s MQTT server. It connects to other mqtt brokers. Any ideas/common configs that can cause connection issues?

Could it be due to victron using protocol version mqtt5?

Likely mqtt5, under the covers we are using this library for the Mqtt connection, GitHub - knolleary/pubsubclient: A client library for the Arduino Ethernet Shield that provides support for MQTT.

Personally I use mosquito as my mqtt server

Just tested with mosquitto_pub -V 311 and 31 and can send to victron server so dont think that’s it. Any other ideas?

I have no issue connecting to “normal” MQTT server (0 config mosquitto server) and i can view mqtt via mqtt explorer. As you can see here, the server is receiving data from esp32 device:

However it fails to connect on victron mqtt server. I thought maybe the initial message structure was causing the issue or maybe even mqtt version being too high on victron server but i tested using the command:

mosquitto_pub -h 192.168.3.104 -t home/T/RFtoMQTT -m ‘{“active”:3,“frequency”:433.92,“rssithreshold”:-105,“rssi”:-113,“avgrssi”:-114,“count”:0,“ookthreshold”:11}’ -V mqttv31

Maybe your base topic ? I’m kinda stumped

Thanks for taking a look.

I’ve found where victron saves their broker logs. (FlashMQ is what they’re using).

I think I need to somehow remove username rather than sending empty string.
Guessing mosquitto is smart enough to handle this and treat as no username but maybe flashmq isnt? (Is there a quick way to edit this in the openmqtt, no worries if not i’ll just hard code it)

The logs:

[NOTICE] Accepting connection from: address='192.168.3.171', transport='TCP/Non-SSL', fd=20
@400000006634a27f14660db4 [2024-05-03 08:38:13.341] [ERROR] Unspecified or non-MQTT protocol error: Username flagged as present, but it's 0 bytes.. Removing client.
@400000006634a27f14662524 [2024-05-03 08:38:13.341] [NOTICE] Removing client '[ClientID='', username='', fd=20, keepalive=10s, transport='TCP/Non-SSL', address='192.168.3.171', prot=3.1.1, clean=0]'. Reason(s): Username flagged as present, but it's 0 bytes.

Or change the victron config to work similar to mosquito and allow_anonymous connections. Or define a username /password config in victrjn and the OMG config panel

Thanks again,
I’m reluctant to edit the Victron side as it’ll get upgraded more often than the openmqqt side (it’s C++ using flashmq which they’re recently swapped to from python so not sure how easy it is to edit/not sure it’s got config file for setting user credentials so might need to be recompiled to enable username/password every time the victron systems upgrade).

For testing I was planning on changing main.ino from:

if (client.connect(gateway_name, mqtt_user, mqtt_pass, topic, will_QoS, will_Retain, will_Message)) {

to this:

bool conn;
if(mqtt_user == "" && mqtt_pass == ""){
conn = client.connect(gateway_name, NULL, NULL, topic, will_QoS, will_Retain, will_Message);
//or is this better:
//conn = client.connect(gateway_name, topic, will_QoS, will_Retain, will_Message);

}else{
conn = client.connect(gateway_name, mqtt_user , mqtt_pass , topic, will_QoS, will_Retain, will_Message);
}

if (conn)) { 
...code continues as normal

Any red flags/issues you can spot with that plan?

That looks reasonable ( maybe a log entry so that you can confirm it is working correctly ? )

Thanks, i had to tweak it to this as they’re empty rather than empty string but this solved it, thanks again.

bool conn=false;

  if((mqtt_user == "" && mqtt_pass == "") || ((mqtt_user[0] == '\0' && mqtt_pass[0] == '\0') || (strlen(mqtt_user) == 0 && strlen(mqtt_pass) == 0))){

    conn = client.connect(gateway_name, NULL, NULL, topic, will_QoS, will_Retain, will_Message);
    Log.warning(F("NULL case" CR));
  }else{

    conn = client.connect(gateway_name, mqtt_user, mqtt_pass, topic, will_QoS, will_Retain, will_Message);
  Log.warning(F("default case" CR));
  Log.warning(F("mqttUser %s, mqttPass %s" CR), mqtt_user, mqtt_user);
  }



  if (conn) {