I want nRF9160 to do mqtts connection without certificate.
Modem FW:1.2.3
Here is my mqtt client_init:
static int client_init(struct mqtt_client *client)
{
int err;
mqtt_client_init(client);
err = broker_init();
if (err) {
LOG_ERR("Failed to initialize broker connection");
return err;
}
/* MQTT client configuration */
client->broker = &broker;
client->evt_cb = mqtt_evt_handler;
client->client_id.utf8 = (uint8_t *)CONFIG_MQTT_CLIENT_ID;
client->client_id.size = strlen(CONFIG_MQTT_CLIENT_ID);
client->password = NULL;
client->user_name = NULL;
client->protocol_version = MQTT_VERSION_3_1_1;
/* MQTT buffers configuration */
client->rx_buf = rx_buffer;
client->rx_buf_size = sizeof(rx_buffer);
client->tx_buf = tx_buffer;
client->tx_buf_size = sizeof(tx_buffer);
/* MQTT transport configuration */
struct mqtt_sec_config *tls_cfg = &(client->transport).tls.config;
static sec_tag_t sec_tag_list[] = { CONFIG_MQTT_TLS_SEC_TAG };
LOG_INF("TLS enabled");
client->transport.type = MQTT_TRANSPORT_SECURE;
tls_cfg->peer_verify = TLS_PEER_VERIFY_NONE;
tls_cfg->cipher_count = 0;
tls_cfg->cipher_list = NULL;
tls_cfg->sec_tag_count = 0;
tls_cfg->sec_tag_list = NULL;
tls_cfg->hostname = CONFIG_MQTT_BROKER_HOSTNAME;
tls_cfg->session_cache = IS_ENABLED(CONFIG_MQTT_TLS_SESSION_CACHING) ?
TLS_SESSION_CACHE_ENABLED :
TLS_SESSION_CACHE_DISABLED;
return err;
}
When I use 9160DK, mqtts is connected normally. But when using the 9160 chip, there is an error in the connection. Here is my log:
[00:00:00.243,316] [0m<inf> main: Connecting to LTE network.[0m
[00:00:00.243,316] [0m<inf> main: This may take several minutes.[0m
[00:00:00.243,377] [0m<inf> flash_control: No apn found, use default apn[0m
[00:00:00.249,908] [0m<inf> main: Set to the default APN CMNBIOT2.[0m
[00:00:00.258,087] [0m<inf> lte_lc: Using legacy LTE PCO mode...[0m
[00:00:02.258,117] [0m<inf> main: CSCON : 1[0m
[18:48:50.833]收←◆[00:00:04.283,386] [0m<inf> main: Connected to LTE network.[0m
[00:00:04.286,163] [0m<inf> mqtt_engine: IPv4 Address found 47.106.164.80[0m
[00:00:04.286,193] [0m<inf> mqtt_engine: TLS enabled[0m
[00:00:04.286,468] [0m<dbg> net_mqtt_sock_tls.mqtt_client_tls_connect: (0x20015220): Created socket 1[0m
[00:00:04.660,552] [1;31m<err> mqtt_engine: mqtt_connect -45[0m
[00:00:04.660,583] [1;31m<err> mqtt_engine: ERROR: mqtt_disconnect -57[0m
-45 is EOPNOTSUPP, and typically indicates that you have written wrong certificates to the device. But I had peer_verify set to 0. Why is there a -45 error?