Skip to content

INFO & CLUSTER commands failed when using RESP3 #802

Closed
@carlosabalde

Description

@carlosabalde

The following toy implementation shows how execution of INFO command using current RESP3 support in master fails with error Protocol error, got "=" as reply type byte. This has been tested using Redis Server 6.0.1. Same logic using RESP2 works as expected.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <hiredis/hiredis.h>

#define HOST "127.0.0.1"
#define PORT 6400

static redisContext *connect(unsigned version)
{
    redisContext *ctx = redisConnect(HOST, PORT);
    assert(ctx != NULL);
    if (ctx->err) {
        printf("CONNECT: %s\n", ctx->errstr);
    }
    assert(ctx != NULL && !ctx->err);

    redisReply *reply = redisCommand(ctx, "HELLO %d", version);
    if (ctx->err) {
        printf("HELLO: %s\n", ctx->errstr);
    }
    assert(
        !ctx->err && reply != NULL &&
        ((version == 2 && reply->type == REDIS_REPLY_ARRAY) ||
         (version == 3 && reply->type == REDIS_REPLY_MAP)));
    freeReplyObject(reply);

    return ctx;
}

int
main(int argc, char *argv[])
{
    redisContext *ctx = connect(3);
    redisReply *reply = redisCommand(ctx, "INFO");
    if (ctx->err) {
        printf("INFO: %s\n", ctx->errstr);
    }
    assert(!ctx->err && reply != NULL);
    printf("%s\n", reply->str);
    freeReplyObject(reply);
}

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions