Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpp 的sdk 能否和C 一样设置,当连续网速较低时,判断为超时 #6

Closed
keguo1119 opened this issue Mar 27, 2019 · 2 comments

Comments

@keguo1119
Copy link

#include "oss_api.h"
#include "aos_http_io.h"
const char *endpoint = "<yourEndpoint>";
const char *access_key_id = "<yourAccessKeyId>";
const char *access_key_secret = "<yourAccessKeySecret>";
void init_options(oss_request_options_t *options)
{
    options->config = oss_config_create(options->pool);
    /* 用char*类型的字符串初始化aos_string_t类型。*/
    aos_str_set(&options->config->endpoint, endpoint);
    aos_str_set(&options->config->access_key_id, access_key_id);
    aos_str_set(&options->config->access_key_secret, access_key_secret);
    /* 是否使用了CNAME。0表示不使用。*/
    options->config->is_cname = 0;
    /* 用于设置网络相关参数,其中这个函数的第二个参数表示ctl的归属,默认为0。*/
    options->ctl = aos_http_controller_create(options->pool, 0);
    /* 设置链接超时,默认是10秒。*/
    options->ctl->options->connect_timeout = 10;
    /* 设置DNS超时,默认是60秒。*/
    options->ctl->options->dns_cache_timeout = 60;
    /* 
    设置请求超时:
    通过设置speed_limit的值控制能容忍的最小速率,默认是1024,即1KB/s。
    通过设置speed_time的值控制能容忍的最长时间,默认是15秒。
    表示如果传输速率连续15秒小于1KB/s,则超时。
    */
    options->ctl->options->speed_limit = 1024;
    options->ctl->options->speed_time = 15;
}
@huiguangjun
Copy link
Collaborator

C++ SDK 中的  ClientConfiguration.requestTimeoutMs  与 c sdk 中的 设置请求超时参数的用法是一样的。 只不过在c++ sdk里, speed_limit 固定为 1.

@keguo1119
Copy link
Author

也就是这个 speed_limit 暂时不支持动态修改呗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants