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

Callback for xadd #1471

Closed
mikeslim7 opened this issue Nov 1, 2019 · 9 comments
Closed

Callback for xadd #1471

mikeslim7 opened this issue Nov 1, 2019 · 9 comments
Labels

Comments

@mikeslim7
Copy link

Hello,

Is there a way to have a callback for xadd something like:

redisClient.xadd(streamName, '*',....,function(err,resp){
console.log(resp);
});

I tried and had errors.

Thanks!
Mike

@stockholmux
Copy link
Contributor

@mikeslim7 this exists. Can you please post real code (instead ....) as I think it might just be an small error.

@protectedvar
Copy link

protectedvar commented Nov 29, 2019

I have an error than call

redisClient.xadd('mystream', '*', 'field1', 'm1', function (err) {
});

{ ReplyError: ERR unknown command `xadd`, with args beginning with: `mystream`, `*`, `field1`, `m1`, 
    at parseError (/home/work/node_modules/redis-parser/lib/parser.js:193:12)
    at parseType (/home/work/node_modules/redis-parser/lib/parser.js:303:14)
  command: 'XADD',
  args: [ 'mystream', '*', 'field1', 'm1' ],
  code: 'ERR' }

@stockholmux
Copy link
Contributor

@protectedvar You have a version of Redis that doesn't support streams (unrelated to this issue).

@gcobcqwe
Copy link

gcobcqwe commented Dec 9, 2019

@stockholmux Does v2.8.0 support xadd callback?

@stockholmux
Copy link
Contributor

@gcobcqwe Yes.

@hbel
Copy link

hbel commented Dec 30, 2019

I have the same problem with the latest version node_redis (2.8.0?). I also tried to directly use the master branch, with throws the same error.

The following code does not run.

const rdb = redis.createClient("redis://localhost:6379");
const send = promisify(rdb.sendCommand).bind(rdb);
const n = {forename: "foo", lastname: "bar"};
send(`XADD nameStream * ${JSON.stringify(n)}`).catch(e => console.error(e));

ReplyError: ERR unknown command xadd namestream * {"forename":"foo","lastname":"bar"}, with args beginning with:
at parseError (/Users/hendrik/git/ownprojects/databroker/node_modules/redis-parser/lib/parser.js:193:12)
at parseType (/Users/hendrik/git/ownprojects/databroker/node_modules/redis-parser/lib/parser.js:303:14) {
command: 'XADD NAMESTREAM * {"FORENAME":"FOO","LASTNAME":"BAR"}',
code: 'ERR'
}

@gcobcqwe
Copy link

Hey, @hbel. I think your format is incorrect.
XADD mystream * field1 value1 field2 value2 field3 value3
https://redis.io/commands/xadd

@BridgeAR
Copy link
Contributor

BridgeAR commented Feb 5, 2020

The error posted here indicates the error came directly from the Redis server, not from the client. Thus, I am closing this issue.

@dannoshepard
Copy link

For anyone who might be reading this and saying wtf...

The first argument to the send command functions need to be the command by its self. In the case of @hbel the Redis server literally thought the command was xadd namestream * {"forename":"foo","lastname":"bar"}.. instead he should have wrote send( "XADD", [nameStream "*", JSON.stringify(n)] ).catch(e => console.error(e));

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

No branches or pull requests

7 participants