报错errMsg": "request:fail abort statusCode:-1 Unexpected status line:

77 阅读1分钟

使用uniapp的uni.request来调用接口时,遇到了匪夷所思的情况:第奇数次数调用接口时,请求成功,而第偶数次数调用接口时,进入了fail回调函数里,而且必现(即:第1、3、5次请求成功,第2、4、6次失败)。

image.png

image.png

{
    "errMsg": "request:fail abort statusCode:-1 Unexpected status line:    {\"uhf\":\"\",\"code\":0,\"message\":\"没有读取到数据\"}HTTP/1.1 200 OK"
}

试了添加sslVerify: false、dataType: 'json'、responseType: 'text'等网上常见解决方法,统统没有效果。

最后在调用uni.request时,增加了属性firstIpv4: true,成功~~