Help Center/ Object Storage Service/ SDK Reference/ C/ FAQs (SDK for C)/ Invalid Proxy Settings (SDK for C)
Updated on 2026-08-03 GMT+08:00

Invalid Proxy Settings (SDK for C)

Problem 1: After a Proxy Is Configured in the Windows Demo, An Error Is Reported and the Proxy Settings Do Not Take Effect.

Symptom:

After a proxy is configured in the Windows demo, an error is reported and the proxy settings do not take effect.

Root cause:

In some SDK versions, the demo header file eSDKOBS.h is not updated synchronously with the SDK header file. As a result, the demo lacks new structure members (like obs_upload_file_server_callback), causing the proxy settings to become invalid.

Solution:

  1. (Recommended) Upgrade the SDK to the latest version.
  2. To use an earlier version, copy source/eSDK_OBS_API/eSDK_OBS_API_C++/build/obs/demo/eSDKOBS.h in the SDK installation directory to the source/eSDK_OBS_API/eSDK_OBS_API_C++/inc/ directory to replace the original file, and adjust the demo code based on the API changes in the new header file.

Problem 2: The Proxy is Configured but the Connection Still Fails.

Symptom:

After proxy_host and proxy_auth are correctly configured using obs_http_request_option, some requests still fail to be connected.

Root cause:

The get_api_version function in the SDK does not read the proxy settings. As a result, the requests are not sent through the proxy channel. This is a known defect of the SDK.

Solution:

Upgrade the SDK to the latest version. To temporarily resolve this issue, add the setting logic of CURLOPT_PROXY and CURLOPT_PROXYUSERPWD to the get_api_version function of the SDK source code request.c by referring to the method for configuring the proxy in the setup_curl function.

How to Configure the Proxy

Configure the proxy using obs_http_request_option. For details about related parameters, see Configuring option (SDK for C).

#include "eSDKOBS.h"
#include <stdio.h>
int main()
{
    obs_status ret_status = obs_initialize(OBS_INIT_ALL);
    if (OBS_STATUS_OK != ret_status)
    {
        printf("obs_initialize failed(%s).\n", obs_get_status_name(ret_status));
        return -1;
    }
    obs_options options;
    init_obs_options(&options);
    // Enter the endpoint corresponding to the bucket for host_name. CN-Hong Kong is used here as an example. Replace it with the one currently in use.
    options.bucket_options.host_name = "obs.ap-southeast-1.myhuaweicloud.com";
    options.bucket_options.access_key = getenv("ACCESS_KEY_ID");
    options.bucket_options.secret_access_key = getenv("SECRET_ACCESS_KEY");
    options.bucket_options.bucket_name = "example-bucket-name";
    // Set the proxy server.
    options.request_options.proxy_host = "http://proxy.example.com:8080";
    // Set the proxy authentication information. The format is username:password. If no authentication is required, do not set this parameter.
    options.request_options.proxy_auth = "username:password";
    // Service code...
    obs_deinitialize();
    return 0;
}