1.雅特力单片机,(配置移远4G模组),连接阿里云服务器测试公共示例,连接失败
在XShell报错如图所示:
2.自己的应用程序中调用IOT_MQTT_Construct()函数连接阿里云,使用rt-thread操作系统ENV配置的阿里云库,
mqtt_params.handle_event.h_fp = example_event_handle;
pclient = IOT_MQTT_Construct(&mqtt_params);
if (NULL == pclient) {
start_en =1; //连接阿里云失败,进入重启
restart_time_count = 0;
LOG_W("MQTT construct failed");
return ;
}
3.跟进去,在IOT_MQTT_Construct函数中找到问题出在函数ret = wrapper_mqtt_connect(pclient);再跟,执行rc = _mqtt_connect(pClient);出错;再跟,走到函数rc = MQTTConnect(pClient),出错;进去之后,发现连接包错误,走到这里,报上述图片中错误
/* send the connect packet */
iotx_time_init(&connectTimer);
utils_time_countdown_ms(&connectTimer, pClient->request_timeout_ms);
if ((iotx_mc_send_packet(pClient, pClient->buf_send, len, &connectTimer)) != SUCCESS_RETURN) {
mqtt_err("send connect packet failed");
_reset_send_buffer(pClient);
HAL_MutexUnlock(pClient->lock_write_buf);
return MQTT_NETWORK_ERROR;
}
4.用相同的程序,放在CAT模组上能连接上阿里云服务器,我想会不会和模组有关。