MQTT with SSL not working in EC200U

Hi All,

I tested mqtt.dioty.co from MQTT.fx desktop client. I was able to connect successfully using ports 1883 and 8883.
When I tried the same broker from EC200U, port 1883 connected. But port 8883 (with SSL) did not work.
I got error [mqtt_connect_result_cb, 141] mqtt connect status: 254 (MQTT_CONNECT_TCP_CONNECTED_FAILURE)
I verified that “UFS:/dioty.pem” exists.

Sample code below:

extern int pdp_profile_idx;

char *mqttServerDiotyS = "mqtts://mqtt.dioty.co:8883";
char *mqttServerDioty = "mqtt://mqtt.dioty.co:1883";
char *mqttClientIdDioty = "ec200u";
char *mqttUserIdDioty = "my_id@gmail.com";
char *mqttPwdDioty = "my_pwd";

static uint16_t sim_cid = 0;
static mqtt_client_t mqtt_cli;
static struct mqtt_connect_client_info_t client_info = {0};
static bool mqtt_connected = false;

struct mqtt_ssl_config_t mqtt_ssl_cfg = {
	.ssl_ctx_id = 1,
	.verify_level = MQTT_SSL_VERIFY_NONE,
	.cacert_path = "UFS:/dioty.pem",
	.client_cert_path = NULL,
	.client_key_path = NULL,
	.client_key_pwd = NULL
};

void mqttTest(void) {
	if (QL_DATACALL_SUCCESS != ql_bind_sim_and_profile(0, pdp_profile_idx, &sim_cid)) {
		MQTT_TEST_LOG("nSim or profile_idx is invalid!!!!");
		return;
	}

	if (ql_mqtt_client_init(&mqtt_cli, sim_cid) != MQTTCLIENT_SUCCESS) {
		MQTT_TEST_LOG("mqtt client init failed!!!!");
		return;
	}

	MQTT_TEST_LOG("mqtt_cli:%d", mqtt_cli);

	client_info.keep_alive = 60;
	client_info.clean_session = 1;
	client_info.will_qos = 0;
	client_info.will_retain = 0;
	client_info.will_topic = NULL;
	client_info.will_msg = NULL;
	client_info.client_id = mqttClientIdDioty;
	client_info.client_user = mqttUserIdDioty;
	client_info.client_pass = mqttPwdDioty;
	client_info.ssl_cfg = &mqtt_ssl_cfg;

	MQTT_TEST_LOG("connecting to %s", mqttServerDiotyS);

	int ret = ql_mqtt_connect(&mqtt_cli, mqttServerDiotyS, mqtt_connect_result_cb, NULL,
				(const struct mqtt_connect_client_info_t *)&client_info, mqtt_state_exception_cb);

	if (ret == MQTTCLIENT_WOUNDBLOCK) {
		MQTT_TEST_LOG("====wait connect result");
	} else {
		MQTT_TEST_LOG("===mqtt connect failed ,ret = %d", ret);
	}
}

void mqtt_connect_result_cb(mqtt_client_t *client, void *arg, mqtt_connection_status_e status) {
	MQTT_TEST_LOG("mqtt connect status: %d", status);
	if (status == 0) {
		mqtt_connected = true;
	}
}

static void mqtt_state_exception_cb(mqtt_client_t *client) {
	MQTT_TEST_LOG("mqtt session abnormal disconnect");
	mqtt_connected = false;
}

static void mqtt_requst_result_cb(mqtt_client_t *client, void *arg, int err) {
	MQTT_TEST_LOG("mqtt_requst_result_cb: %d", err);
}
1 Like

Getting same error to me…