Symptom
The image component fails to load online images, and network request errors are reported in the onError callback.
Scenario 1
Network request error message is displayed as follows: "Http task of url xxx/xx.png failed, response code 0, msg from netStack: SSL peer certificate or SSH remote key was not OK".
Solution
This type of error is a certificate issue. Currently, the image component does not support caPath configuration. You can use RCP to configure certificate and download the file, and then use the image component to load the local image file.
Scenario 2
Network request error message is displayed as follows: "Http task of url xxx cancelled by netStack".
Solution
This type of error is a network problem, including domain name resolution failure (error code 2300006), server connection failure (error code 2300007) and invalid data returned by the server (error code 2300008). You are advised to check whether the network connection is normal and whether the image URL and server configuration are correct.
Scenario 3
Network request error message is displayed as follows: "Http task of url xxx.jpg response code 0, msg from netStack: URL using bad/illegal format or missing URL".
Solution
This type of error is usually caused by image link problems. For example, the URL contains unescaped spaces, the link is incorrectly spelled, or the HTTP or HTTPS prefix is incorrect. Even if the link is correct, the error may be caused by network problems. For example, the network connection permission ohos.permission.INTERNET is not applied for, or the image can be accessed only through a specific network or VPN.
Scenario 4
Network request error message is displayed as follows: "Http task of url xxx.jpg failed, response code 403".
Solution
This type of error occurs when the server understands the request but refuses to execute the request. It is generally due to file permission settings on the server or the website's security policies blocking access. You can prioritize checking whether the server corresponding to the image link has added configuration-related restrictions such as SSL certificates, referer, or User-Agent.
Reference
SecurityConfiguration: Secure Transmission Customization