Problem with MQTT connection

Using the sodaq sara aff r412m (updated to the latest firmware) and trying the mqtt sketch (modified and adding r4x.mqttSetAuth) I noticed that with some services (example cloudmqtt) it works and with others instead (allthingstalk, ubitodots, cayenne) because they have set a username greater than 30 characters which is the limit of the field (both for username and password)

if (isReady) {
    isReady = r4x.mqttSetServer(MQTT_SERVER_NAME, MQTT_SERVER_PORT) && r4x.mqttSetAuth(MQTT_SERVER_Username, MQTT_SERVER_password) && r4x.mqttLogin();
    CONSOLE_STREAM.println(isReady ? "MQTT connected" : "MQTT failed");
}

how can I fix it?

Hi @scidox,

Thanks for letting us know.
We will investigate and fix the issue.

Best regards,
Jan

Hi scidox,

The latest firmware for the R412 is the M01.10 A02.14

Unfortunately, the 30 character limit is a restriction Ublox have set in their firmware. This can only be changed if they release new firmware with a fix for this.

We have also run into a number of problems with the built in MQTT stack on the R412. I would recommend that you look for a MQTT library that works directly over a TCP socket.

1 Like

the problem is only the login at the cloud service, the library where it connects works perfectly, transmits data quickly and easily and publishes everything with mqttPublish

We also had an issue where the login would fail when connect over 2G (URAT=9).
It would not work if the PDP context was already active.

Hi scidox,

We have now released an adapter library for Sodaq_MQTT to work with the Sodaq_R4X library.
You will need all three libraries:

This uses a direct MQTT implementation over TCP sockets. The main limitation at this point is the size of the topic payloads which are currently limited to 127 bytes.

1 Like

Thanks for the information, I will consider this implementation for the next projects.
I solved using cloudmqtt which sets username and password <30 characters and then I realized all the graphical interface (which would have given me the other online services ready) with node-red.