AWS MQTT IP connect with domain fallback

Hi,

I wonder if there is a smart and easy way to implement a fallback if I use the MQTT connection with a static IP. What I want is if the IP fails to connect it tries again with the defined domain (dns).

Is there already a example for this or a plan for this feature?

best regards 

daniel

Parents
  • Hi Daniel,

    We do not have an example specifically for this feature, but I do not think it is hard to implement such application-level codes.

    You can modify the following codes from github.com/.../main.c add alternative MQTT server options:

    do_connect:
    	if (connect_attempt++ > 0) {
    		LOG_INF("Reconnecting in %d seconds...",
    			CONFIG_MQTT_RECONNECT_DELAY_S);
    		k_sleep(K_SECONDS(CONFIG_MQTT_RECONNECT_DELAY_S));
    	}
    	err = mqtt_connect(&client);
    	if (err != 0) {
    		LOG_ERR("mqtt_connect %d", err);
    		goto do_connect;
    	}
    

    Best regards,

    Charlie

Reply
  • Hi Daniel,

    We do not have an example specifically for this feature, but I do not think it is hard to implement such application-level codes.

    You can modify the following codes from github.com/.../main.c add alternative MQTT server options:

    do_connect:
    	if (connect_attempt++ > 0) {
    		LOG_INF("Reconnecting in %d seconds...",
    			CONFIG_MQTT_RECONNECT_DELAY_S);
    		k_sleep(K_SECONDS(CONFIG_MQTT_RECONNECT_DELAY_S));
    	}
    	err = mqtt_connect(&client);
    	if (err != 0) {
    		LOG_ERR("mqtt_connect %d", err);
    		goto do_connect;
    	}
    

    Best regards,

    Charlie

Children
Related