1

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

Matthew Groves
  • 25,181
  • 9
  • 71
  • 121
kritika arora
  • 55
  • 1
  • 4

1 Answers1

1

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.

chvck
  • 829
  • 10
  • 18
  • I tried without giving the port. But still no luck. Also to add , my Couchbase is present in some other machine and isn't local. If I try the same code for connecting to locally installed Couchbase then I have no problem in connecting through SSL. – kritika arora Sep 29 '21 at 06:10
  • 1
    I'd try enabling logging (https://docs.couchbase.com/c-sdk/current/howtos/collecting-information-and-logging.html) and see if anything jumps out. It should help you to see the reason for the timeout. – chvck Sep 29 '21 at 08:09