libcurl Status Codes (SDK for C)
Overview
The OBS SDK FOR C implements HTTP communication based on libcurl. If curl_easy_perform fails to be executed, the SDK records the libcurl status code (CURLcode) and error information in the log. The format is as follows:
curl_easy_perform failed, CURLcode = 6, curl_error_message is 'Could not resolve host', obs_status = NameLookupError(5), curlErrorBuffer = ...
The key fields are described as follows:
| Field | Description |
|---|---|
| CURLcode | Status code returned by libcurl, which is used to locate underlying network, SSL, or protocol errors |
| curl_error_message | Error message provided by libcurl |
| obs_status | OBS status code mapped from CURLcode by the SDK |
| curlErrorBuffer | Detailed error buffer information of libcurl |
Mapping from CURLcode to OBS Status Codes in the SDK
The SDK uses the request_curl_code_to_status function to map CURLcode to OBS status codes. The mapping is as follows:
| CURLcode | Value | curl_error_message | Mapped OBS Status Code | Description |
|---|---|---|---|---|
| CURLE_OK | 0 | No error | OBS_STATUS_OK | Request succeeded. |
| CURLE_OUT_OF_MEMORY | -1 | Out of memory | OBS_STATUS_OutOfMemory | Memory allocation failed. |
| CURLE_COULDNT_RESOLVE_PROXY | 5 | Couldn't resolve proxy name | OBS_STATUS_NameLookupError | Proxy domain name resolution failed. |
| CURLE_COULDNT_RESOLVE_HOST | 6 | Couldn't resolve host name | OBS_STATUS_NameLookupError | Server domain name resolution failed. |
| CURLE_COULDNT_CONNECT | 7 | Failed to connect to host or proxy | OBS_STATUS_FailedToConnect | Connection to the server or proxy failed. |
| CURLE_WRITE_ERROR | 23 | Write error | OBS_STATUS_ConnectionFailed | Data write failed. |
| CURLE_OPERATION_TIMEDOUT | 28 | Operation timeout | OBS_STATUS_ConnectionFailed | Operation timed out. |
| CURLE_PARTIAL_FILE | 18 | Transferred a partial file | OBS_STATUS_PartialFile | The file is not completely transferred. |
| CURLE_SSL_CACERT | 60 | SSL certificate problem | OBS_STATUS_ServerFailedVerification | SSL certificate verification failed. |
| Others | - | - | OBS_STATUS_InternalError | Errors that are not explicitly mapped by the SDK are classified as internal errors. |
Common CURLcode Fault Locating Guide
CURLE_COULDNT_RESOLVE_HOST (6)
Symptom: The log contains "CURLcode = 6, curl_error_message is 'Could not resolve host'".
Possible causes:
- The DNS configuration is incorrect. As a result, the domain name of the OBS server cannot be resolved.
- The network is disconnected or the DNS server is unreachable.
- The host_name parameter is incorrectly configured (for example, the spelling is incorrect or the domain name suffix is missing).
- The DNS server configuration in the /etc/resolv.conf file is incorrect.
Fault locating procedure:
- Check whether the value of options.bucket_options.host_name is correct. It should be the domain name of the OBS server, for example, obs.cn-north-4.myhuaweicloud.com.
- Run the nslookup obs.cn-north-4.myhuaweicloud.com command on the server to verify DNS resolution.
- Check the DNS server configuration in the /etc/resolv.conf file.
- Add the IP address mapping of the OBS server to the /etc/hosts file for temporary verification.
CURLE_COULDNT_CONNECT (7)
Symptom: The log contains "CURLcode = 7, curl_error_message is 'Failed to connect to host or proxy'".
Possible causes:
- The network is disconnected, and the TCP connection to the OBS server cannot be established.
- The firewall or security group rules block outbound access.
- The proxy configuration is incorrect.
- The OBS server ports (80 for HTTP and 443 for HTTPS) are blocked.
Fault locating procedure:
- Run the telnet obs.cn-north-4.myhuaweicloud.com 443 command to verify the TCP connectivity.
- Check the firewall rules and security group configurations to ensure that outbound traffic on port 443 is allowed.
- If a proxy is used, check whether options.request_options.proxy_host is correctly configured.
- Run the curl -v https://obs.cn-north-4.myhuaweicloud.com command to test the connectivity.
CURLE_OPERATION_TIMEDOUT (28)
Symptom: The log contains "CURLcode = 28, curl_error_message is 'Operation timeout'".
Possible causes:
- The network latency is too high, and the request is not completed within the specified timeout interval.
- The timeout interval specified for uploading or downloading large files is too short.
- The server responds slowly.
- The rate limit is too low. As a result, the transmission times out.
Fault locating procedure:
- Check whether options.request_options.connect_time (connection timeout interval, in seconds) is set properly.
- Check the settings of options.request_options.speed_time and speed_limit.
- For large file transfer, increase the values of connect_time and max_connected_time.
- Check the network bandwidth and latency.
CURLE_SSL_CACERT (60)
Symptom: The log contains "CURLcode = 60, curl_error_message is 'SSL certificate problem'".
Possible causes:
- The server does not have the CA certificate package.
- The certificate file specified by options.request_options.server_cert_path does not exist or is in an incorrect format.
- A man-in-the-middle (MITM) attack occurs or the certificate is tampered with.
- libcurl is not properly linked with OpenSSL during compilation.
Fault locating procedure:
- Run the ls /etc/ssl/certs/ command to check whether the CA certificate package is installed.
- If server_cert_path is set, verify the certificate file path and certificate format.
- Run the curl -v https://obs.cn-north-4.myhuaweicloud.com command to verify the SSL handshake.
- To skip certificate verification (only in the test environment), check whether related options are enabled during compilation.
CURLE_PARTIAL_FILE (18)
Symptom: The log contains "CURLcode = 18, curl_error_message is 'Transferred a partial file'".
Possible causes:
- The network is disconnected during transmission.
- The connection is closed on the server in advance.
- The disk space is insufficient. As a result, the write operation fails.
- The connection is unstable when a large file is downloaded.
Fault locating procedure:
- Check the network stability.
- Check whether the disk space is insufficient.
- Use the resumable download API (download_file) to download large files.
- Check whether the value of Content-Length returned by the server is the same as the actual data volume.
CURLE_WRITE_ERROR (23)
Symptom: The log contains "CURLcode = 23, curl_error_message is 'Write error'".
Possible causes:
- The callback function returns an error, causing the write operation to be aborted.
- Data fails to be written to the local disk.
- An exception occurs during the execution of the callback function.
Fault locating procedure:
- Check the logic of the put_object_data_callback or get_object_data_callback callback function.
- Verify that the callback function returns the correct value. (The upload callback should return the number of written bytes. Any non-zero status code indicates an error.)
- Check the disk space and file permissions.
CURLE_OUT_OF_MEMORY (-1/other values)
Symptom: The log contains "CURLcode = -1" or memory-related errors.
Possible causes:
- The available system memory is insufficient.
- The buffer fails to be allocated when a large file is uploaded.
- The available memory decreases due to memory leakage.
Fault locating procedure:
- Run the free -m command to check the system memory usage.
- Use multipart upload instead of one-off upload to upload large files.
- Check whether memory leakage occurs.
- Adjust the value of options.request_options.buffer_size.
CURLE_COULDNT_RESOLVE_PROXY (5)
Symptom: The log contains "CURLcode = 5, curl_error_message is 'Couldn't resolve proxy name'."
Possible causes:
- The proxy server domain name is incorrectly configured.
- The proxy server domain name cannot be resolved.
Fault locating procedure:
- Check the options.request_options.proxy_host configuration format. The format must be hostname:port or http://hostname:port.
- Run the nslookup command to verify the proxy domain name resolution.
- If no proxy is required, ensure that proxy_host is not set.
CURLcode Troubleshooting Procedure in Logs
- Find CURLcode = X in the SDK logs.
- Based on X, refer to this document to determine the error type.
- Locate and rectify the fault according to the corresponding locating procedure.
- If the returned CURLcode is not in the mapping table of this document, the error is not explicitly mapped. In this case, the SDK returns OBS_STATUS_InternalError. For details, see the official libcurl documentation.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot