Page 1 of 1

mqtt_message_receive error trying to connect to broker

Posted: Tue Apr 28, 2020 10:51 am
by AleGiaco
Hi,

I'm trying to connect to my broker with the esp32 mqtt ssl template but I get this errors:

I (7091) MQTT_CLIENT: Sending MQTT CONNECT message, type: 1, id: 0000
E (7131) MQTT_CLIENT: mqtt_message_receive: transport_read() error: errno=128
E (7131) MQTT_CLIENT: esp_mqtt_connect: mqtt_message_receive() returned -1
I (7131) MQTT_CLIENT: Error MQTT Connected
I (7141) MQTTS_EXAMPLE: MQTT_EVENT_DISCONNECTED

The configuration is classic:

Code: Select all

    const esp_mqtt_client_config_t mqtt_cfg = {
        .uri = CONFIG_BROKER_URI,
        .cert_pem =  (const char *)mqtt_eclipse_org_pem_start,
    };
with
CONFIG_BROKER_URI = mqtt://myBrokerUri:port
and
in mqtt_eclipse_org_pem_start I setted the route of my certificate via Broker certificate override: certs/myCert.pem

I tried to connect to hivemq.com and I had no difficulties so i think the problem is that eclipse doesn't see the certificate.

Someone can help me?

Regards

Re: mqtt_message_receive error trying to connect to broker

Posted: Tue Jul 07, 2020 12:15 pm
by pollock694
Could you try specifying these parameters too?

Code: Select all

         
         .port = MQTT_PORT,
	 .transport = MQTT_TRANSPORT_OVER_SSL,
         .cert_pem = (const char *)mqtt_eclipse_org_pem_start,
 	.username = MQTT_USER_NAME,
 	.password = MQTT_PASSWORD,
 	.client_id = MQTT_CLIENT_ID,
 	.keepalive = MQTT_KEEPALIVE
		

Re: mqtt_message_receive error trying to connect to broker

Posted: Wed Jul 08, 2020 1:31 am
by ESP-Marius
Your issue is probably that you are setting your uri to

Code: Select all

mqtt://
when it should be

Code: Select all

mqtts://
With mqtt:// you get a plain TCP connection without SSL, but you are probably connecting to a port/broker which expects SSL, so it rejects your connection.