I'm trying to connect to an MQTT server and I found the next problem.
when setting the parameters one by one, like this:
Code: Select all
esp_mqtt_client_config_t mqtt_cfg;
memset(&mqtt_cfg, 0, sizeof(esp_mqtt_client_config_t));
mqtt_cfg.host = (char *)hostname;
mqtt_cfg.port = port;
mqtt_cfg.client_id = (char *)client_id;
mqtt_cfg.username = (char *)username;
mqtt_cfg.password = (char *)password;
mqtt_cfg.cert_pem = (const char *)mqttserver_pub_pem_start;
esp_mqtt_set_config(mqtt_client, &mqtt_cfg);
Code: Select all
I (6178) esp_netif_handlers: sta ip: 192.168.1.22, mask: 255.255.255.0, gw: 192.168.1.1
I (6178) mqtt: MQTT_EVENT_BEFORE_CONNECT
E (6258) TRANS_TCP: DNS lookup failed err=202 res=0x0
E (6258) MQTT_CLIENT: Error transport connect
I (6258) mqtt: MQTT_EVENT_ERROR
I (6258) mqtt: MQTT_EVENT_DISCONNECTED
Code: Select all
esp_mqtt_client_config_t mqtt_cfg =
{
.uri = (char *)hostname,
.cert_pem = (const char *)mqttserver_pub_pem_start,
.port = port,
.client_id = (char *)client_id,
.username = (char *)username,
.password = (char *)password,
};
esp_mqtt_set_config(mqtt_client, &mqtt_cfg);
Code: Select all
I (4159) esp_netif_handlers: sta ip: 192.168.1.22, mask: 255.255.255.0, gw: 192.168.1.1
I (4159) mqtt: MQTT_EVENT_BEFORE_CONNECT
I (6339) mqtt: MQTT_EVENT_CONNECTED
Best regards,
P