简体   繁体   中英

Couchbase 7 Connection Issue with SSL

I am trying to connect to couchbase 7 using c sdk 3.2 using ssl but i always end up getting timeout error on LCB_WAIT.All other lcb call returns success but on reaching lcb_wait i end up getting timeout error Below is my code snippet:

const char *connection_string = "couchbases://104.xx.xx.xx:8091/travel?certpath=C:/Users/KArora/Downloads/couch.cert";
    const char *username = "XXXXX";
    const char *password = "XXXX";
    const char *pbucket = "travel";
    const char * errMsg = "";

    lcb_STATUS rc;
    lcb_CREATEOPTS *options = NULL;

    rc = lcb_createopts_create(&options, LCB_TYPE_BUCKET);

    if (rc != LCB_SUCCESS)
        errMsg = lcb_strerror_long(rc);

    rc = lcb_createopts_connstr(options, connection_string, strlen(connection_string));
    if (rc != LCB_SUCCESS)
        errMsg = lcb_strerror_long(rc);

    rc = lcb_createopts_credentials(options, username, strlen(username), password, strlen(password));
    if (rc != LCB_SUCCESS)
        errMsg = lcb_strerror_long(rc);

    rc = lcb_createopts_bucket(options, pbucket, strlen(pbucket));
    if (rc != LCB_SUCCESS)
        errMsg = lcb_strerror_long(rc);



    lcb_INSTANCE *instance = NULL;
    rc = lcb_create(&instance, options);
    if (rc != LCB_SUCCESS)
        errMsg = lcb_strerror_long(rc);

    rc = lcb_connect(instance);
    if (rc != LCB_SUCCESS)
        errMsg = lcb_strerror_long(rc);

    lcb_createopts_destroy(options);
    if (rc != LCB_SUCCESS)
    {
        errMsg = lcb_strerror_long(rc);
        std::cout << errMsg << std::endl;
    }
    else
    {
        std::cout << "SUCCESS" << std::endl;
    }

    *****rc = lcb_wait(instance, LCB_WAIT_DEFAULT);*****
    if (rc != LCB_SUCCESS)
        errMsg = lcb_strerror_long(rc);

    //assert(lcb_get_bootstrap_status(m_instance) == LCB_SUCCESS);
    rc = lcb_get_bootstrap_status(instance);
    if (rc != LCB_SUCCESS)
        errMsg = lcb_strerror_long(rc);


    return 0;
}

LCB_ERR_TIMEOUT (201)The error code i get

Have you tried without the :8091 in the connection string? I'm unsure if libcouchbase does any port translation but 8091 is the non-SSL HTTP management port. I think that you actually want to connect over the SSL KV port, if you don't specify a port then libcouchbase should figure out what to use automatically.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM