hardware: nRF9160 DK 0.8.2
firmware: 0.7.0-29.alpha
I want to send data every a few seconds through MQTT. It fails in the first and second Tx after MQTT client initiation, and succeeds after that. It releases error = -57.
Why does it fails in the first and second Tx after initiation?
I tested the code below. I added four lines to mqtt_simple.
mqtt_simple: https://github.com/NordicPlayground/fw-nrfconnect-nrf/blob/master/samples/nrf9160/mqtt_simple/src/main.c
<main.c>
.
.
.
void main(void)
{
int err;
printk("The MQTT simple sample started\n");
modem_configure();
client_init(&client);
err = mqtt_connect(&client);
if (err != 0) {
printk("ERROR: mqtt_connect %d\n", err);
return;
}
err = fds_init(&client);
if (err != 0) {
printk("ERROR: fds_init %d\n", err);
return;
}
k_sleep(20*1000); // ADD HERE
err = data_publish(&client, MQTT_QOS_0_AT_MOST_ONCE, "a", strlen("a")); // ADD HERE
printk("err=%d\n", err); // ADD HERE
printk("Send reset message\n"); // ADD HERE
while (1) {
.
.
.
and the result is here. err=-57
***** Booting Zephyr OS v1.14.99-ncs1 *****
The MQTT simple sample started
LTE Link Connecting ...
LTE Link Connected!
IPv4 Address found 0x????????
Publishing: a
to topic: myPubTopic len: 10
err=-57
Send reset message
mqtt_input start
[mqtt_evt_handler:168] MQTT client connected!
Subscribing to: mySubTopic len 10
mqtt_input end
mqtt_input start
[mqtt_evt_handler:218] SUBACK packet id: 1234
mqtt_input end
Any advice?