Sodaq SARA + VODAFONE problem with MQTT

Hello.
I have a problem with the MQTT connection using Sodaq Sara + vodafone. In fact, initially it did not connect to the network, subsequently changing the settings I managed, however now to fail is the MQTT connection. Can someone help me?

#define VODAFONE_NBIOT

#elif defined(VODAFONE_NBIOT)
#define CURRENT_APN “nb.inetd.gdsp”
#define CURRENT_OPERATOR AUTOMATIC_OPERATOR
#define CURRENT_URAT SODAQ_R4X_NBIOT_URAT
#define CURRENT_MNO_PROFILE MNOProfiles::SIM_ICCID (
I changed this parameter from the default one that had VODAFONE as input because only in this way could I connect to the network)

#define NBIOT_BANDMASK “524288”

Then I set the port and the name of the server. But it doesn’t work.

thank you

Hi @ANTONELLA_LOMBARDO,

Can you share a logfile where we can see what the modem is actually doing?

Did you already see these MQTT suggestion?
https://support.sodaq.com/Boards/Sara_AFF/faq/#mqtt

Best regards,
Jan

#include <Sodaq_R4X.h>

#define CONSOLE_STREAM SerialUSB
#define MODEM_STREAM Serial1

#define VODAFONE_NBIOT

#if defined(MONOGOTO)
#define CURRENT_APN “data.mono”
#define CURRENT_OPERATOR AUTOMATIC_OPERATOR
#define CURRENT_URAT SODAQ_R4X_LTEM_URAT
#define CURRENT_MNO_PROFILE MNOProfiles::STANDARD_EUROPE
#elif defined(VODAFONE_LTEM)
#define CURRENT_APN “live.vodafone.com
#define CURRENT_OPERATOR AUTOMATIC_OPERATOR
#define CURRENT_URAT SODAQ_R4X_LTEM_URAT
#define CURRENT_MNO_PROFILE MNOProfiles::VODAFONE
#elif defined(VODAFONE_NBIOT)
#define CURRENT_APN “nb.inetd.gdsp”
#define CURRENT_OPERATOR AUTOMATIC_OPERATOR
#define CURRENT_URAT SODAQ_R4X_NBIOT_URAT
#define CURRENT_MNO_PROFILE MNOProfiles::SIM_ICCID
#define NBIOT_BANDMASK “524288”
#elif defined(CUSTOM)
#define CURRENT_APN “[your apn]”
#define CURRENT_OPERATOR AUTOMATIC_OPERATOR
#define CURRENT_URAT SODAQ_R4X_LTEM_URAT
#define CURRENT_MNO_PROFILE MNOProfiles::SIM_ICCID
#else
#error “Please define a operator”
#endif

#define MQTT_SERVER_NAME “test.mosquitto.org
#define MQTT_SERVER_PORT 1883

#ifndef NBIOT_BANDMASK
#define NBIOT_BANDMASK BAND_MASK_UNCHANGED
#endif

static Sodaq_R4X r4x;
static Sodaq_SARA_R4XX_OnOff saraR4xxOnOff;
static bool isReady;

void setup()
{
while ((!CONSOLE_STREAM) && (millis() < 10000)){
// Wait max 10 sec for the CONSOLE_STREAM to open
}

CONSOLE_STREAM.begin(115200);
MODEM_STREAM.begin(r4x.getDefaultBaudrate());

r4x.setDiag(CONSOLE_STREAM);
r4x.init(&saraR4xxOnOff, MODEM_STREAM);

isReady = r4x.connect(CURRENT_APN, CURRENT_URAT, CURRENT_MNO_PROFILE, CURRENT_OPERATOR, BAND_MASK_UNCHANGED, NBIOT_BANDMASK);

CONSOLE_STREAM.println(isReady ? "Network connected" : "Network connection failed");

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

if (isReady) {
    uint8_t buf0[] = {'t', 'e', 's', 't', '0'};
    uint8_t buf1[] = {'t', 'e', 's', 't', '1'};

    r4x.mqttPublish("/home/test/test0", buf0, sizeof(buf0));
    r4x.mqttPublish("/home/test/test1", buf1, sizeof(buf1), 0, 0, 1);
    r4x.mqttSubscribe("/home/test/#");
}

CONSOLE_STREAM.println("Setup done");

}

I used the example of the library but I use one of my server and not “test.mosquitto.org”.
Yes I checked between the tips and the URC is a zero resistance so I don’t think that’s the problem.

the result is “MQTT failed”