HarmonyOS 鸿蒙Next https访问多次报错,windows下同个api访问正常
HarmonyOS 鸿蒙Next https访问多次报错,windows下同个api访问正常
刚刚在测试OpenHarmony的https功能,在chrome访问两个https的api
两个api一个是线上的,一个是本地局域网内搭建的https服务器
windows访问正常且有数据返回
openHarmony Release3.1版本访问 https://tcc.taobao.com/cc/json/mobile_tel_segment.htm?tel=13184825794
报错
NetMgrSubsystem: NETSTACK [http_exec.cpp 95] request fail, url:https://tcc.taobao.com/cc/json/mobile_tel_segment.htm?tel=13184825794, Couldn’t resolve host name 6
config.json 中相关配置如下
更多关于HarmonyOS 鸿蒙Next https访问多次报错,windows下同个api访问正常的实战教程也可以访问 https://www.itying.com/category-93-b0.html
开发者你好,目前该网址https://tcc.taobao.com/cc/json/mobile_tel_segment.htm?tel=13184825794 在windows上无法访问,无法进一步定位原因。烦请提供完整的日志,并确认在开发板上能ping通tcc.taobao.com,多谢!~
更多关于HarmonyOS 鸿蒙Next https访问多次报错,windows下同个api访问正常的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html
今天测试 该网址https://tcc.taobao.com/cc/json/mobile_tel_segment.htm?tel=13184825794 在windows上是可以访问的 回复中没有办法贴图 请留意该网址的返回数据就行了,返回的不是网页。
使用的代码如上
import http from '@ohos.net.http';
@Component
struct Index {
@State message: string = 'Hello World'
private aboutToAppear(): void {
console.info('=======test2')
let httpRequest = http.createHttp();
httpRequest.on('headersReceive', (header) => {
console.info('header: ' + JSON.stringify(header));
console.info('=======test3')
});
httpRequest.request(
"https://tcc.taobao.com/cc/json/mobile_tel_segment.htm?tel=13184825793",
{
method: http.RequestMethod.GET,
header: {
'Content-Type': 'application/json'
},
connectTimeout: 60000,
readTimeout: 60000,
}, (err, data) => {
if (!err) {
console.info('=======test4')
console.info('Result:' + data.result);
console.info('code:' + data.responseCode);
console.info('header:' + JSON.stringify(data.header));
console.info('cookies:' + data.cookies);
} else {
console.info('=======test5')
console.info('error:' + JSON.stringify(err));
httpRequest.destroy();
}
}
);
}
@State arr: number[] = [10, 20, 30]
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
之前我们遇到的类似的问题,使用3.2beta1版本就没问题了
你是说IDE的版本吗?我看官网最新的版本是3.0 Beta4,3.2 Beta1哪里可有获取到?
他说的是系统有问题,你重新烧录另一个版本系统看看。
有要学HarmonyOS AI的同学吗,联系我:https://www.itying.com/goods-1206.html
鸿蒙系统版本
- 系统版本: 需要重新烧一个系统
针对帖子标题“HarmonyOS 鸿蒙Next https访问多次报错,windows下同个api访问正常”的问题,以下回答专注于鸿蒙系统相关的可能原因及排查方向:
在鸿蒙系统上访问HTTPS API时出现多次报错,而在Windows系统上同一个API访问正常,可能的原因包括但不限于:
-
证书验证问题:鸿蒙系统可能对SSL/TLS证书的验证更为严格。检查服务器证书是否由受信任的证书颁发机构签发,且证书链完整无误。同时,确认鸿蒙设备上的系统时间准确,因为证书验证会涉及时间有效性检查。
-
网络配置差异:鸿蒙设备和Windows系统的网络配置可能不同,如代理设置、DNS解析等。检查鸿蒙设备的网络配置,确保与Windows系统一致,或尝试直接访问IP地址而非域名。
-
系统API差异:鸿蒙系统和Windows系统在实现HTTPS访问的API上可能存在差异。查阅鸿蒙系统的官方文档,确认使用的API调用方式是否符合鸿蒙系统的规范。
-
资源限制:鸿蒙设备可能存在资源限制(如内存、CPU等),导致在处理HTTPS请求时性能不足。监控设备资源使用情况,评估是否因资源限制导致访问失败。
如果问题依旧没法解决请联系官网客服,官网地址是:https://www.itying.com/category-93-b0.html