So the cluster is operational in production and we are accessing it
via the http interface. The problem comes when I access it via
protobuf. *some* clients connect and run queries just fine, while
others fail to connect with a connection timeout.

This is the library I am using directly, which is the underlying
library used by the http://riak-js.org/ library:
https://github.com/nlf/riakpbc

Below is the code I am using to connect to Riak. From what I have seen
in the library code, the client automatically connects before sending
a request if it isn't already connected.

var RiakDataStore = function (config) {
    var self = this;

    DataStore.call(self, Utils.extend(defaultConfig, config));

    var riakConfig = self.config.riak;

    self.logger.info("Connecting to riak: host = %s, port = %s",
riakConfig.host, riakConfig.port);

    self.riakClient = RiakPBC.createClient({
        host: riakConfig.host,
        port: riakConfig.port
    });
};
Util.inherits(RiakDataStore, DataStore);

RiakDataStore.prototype.storeTile = function (tile, callback) {
    var self = this;

    var bucketName = RiakDataStore.getBucketNameForTile(tile);
    var keyName = tile.getId();

    return self.riakClient.put({
        bucket: bucketName,
        key: keyName,
        content: {
            value: JSON.stringify(tile),
            content_type: 'application/json'
        }
    }, function (err, reply) {
        return callback(err);
    });
};

RiakDataStore.prototype.loadTile = function (tileQuery, callback) {
    var self = this;

    var bucketName = RiakDataStore.getBucketNameForTileQuery(tileQuery);
    var keyName = tileQuery.getId();

    self.riakClient.get({
        bucket: bucketName,
        key: keyName
    }, function (err, reply) {
        if (err) {
            return callback(err, undefined);
        } else if (Array.isArray(reply.content) && reply.content.length) {
            if (reply.content.length > 1) {
                self.logger.warn("Multiple documents returned for
tile: %s (%d versions)", tileQuery.getId(), reply.content.length);
            }

            var tile;

            try {
                tile = DataTile.fromJSON(JSON.parse(reply.content[0].value));
            } catch (ex) {
                return callback(ex, undefined);
            }

            return callback(undefined, tile);
        } else {
            return callback(undefined, null);
        }
    });
};

Thanks,

Alain

On Tue, Dec 3, 2013 at 7:02 AM, Sean Cribbs <[email protected]> wrote:
> First, make sure Riak is working properly, `riak-admin test` will do a
> get/put cycle to make sure your cluster is ok.
>
> Second, double-check what the protobuffs port is in your config file,
> usually 8087.
>
> The pb_backlog will only be a problem when you are rapidly opening
> connections to the server, although we are bumping up the default to 128 for
> Riak 2.0.
>
> Other than those initial guesses, this might be a problem in the library.
> Can you post the code you are using?
>
>
> On Tue, Dec 3, 2013 at 12:04 AM, Alain Rodriguez <[email protected]> wrote:
>>
>> Hi all,
>>
>> I am trying to connect to Riak using the Node.js library
>> https://github.com/nlf/riakpbc, however many of my connections are
>> failing with the error "Connection timeout". Is there a limit on the
>> number of connections allowed over PB? I looked into tuning pb_backlog
>> but it didn't yield any results.
>>
>> As a comparison, I am able to open many concurrent connections via the
>> HTTP interface on the same riak cluster.
>>
>> Is there another protobuf specific configuration that I might be missing?
>>
>> Cheers,
>>
>> Alain
>>
>> _______________________________________________
>> riak-users mailing list
>> [email protected]
>> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
>
>
>
>
> --
> Sean Cribbs <[email protected]>
> Software Engineer
> Basho Technologies, Inc.
> http://basho.com/

_______________________________________________
riak-users mailing list
[email protected]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com

Reply via email to