3rd-Eden / memcached

A fully featured Memcached client build on top of Node.js. Build with scaling in mind so it will support Memcached clusters and consistent hashing.
MIT License
1.31k stars 276 forks source link

Writing Keys from .NET SDK , not able to READ from node js within clustered enviroment #335

Open Himanshu44ec06 opened 5 years ago

Himanshu44ec06 commented 5 years ago

I am writing my Keys from .NET SDK and reading it from NODE JS and my environment is clustered , it was giving me undefined when reading KEY

mapleeit commented 5 years ago

@Himanshu44ec06 Could you please provide more detail:

Which .NET SDK do you use, is reading from .NET SDK normal? What's the type of the value?

A Minimal reproducible example could help me a lot.

drull755 commented 5 years ago

Check if you have CR LF in your data, it causes bugs

#~/memcacheTest# cat test.sh
npm install memcached
echo -n "set keyWithCrLfCrLf 0 0 4\r\n\r\n\r\n\r\n" | nc 127.0.0.1 11211
date
node memcachedtestFAIL.js
date
echo FINISHED
#~/memcacheTest# cat memcachedtestFAIL.js 
const memcached = require('memcached');
const server = new memcached('127.0.0.1:11211', {debug:1});

console.log('START DATA READ');
server.get('keyWithCrLfCrLf', (err, data) => {
        if (err) {
                console.log(err);
        } else {
                console.log('Data received', data);
        }
        process.exit();
});

#~/memcacheTest# chmod +x test.sh 
#~/memcacheTest# ./test.sh 
npm WARN saveError ENOENT: no such file or directory, open '/root/memcacheTest/package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open '/root/memcacheTest/package.json'
npm WARN memcacheTest No description
npm WARN memcacheTest No repository field.
npm WARN memcacheTest No README data
npm WARN memcacheTest No license field.

+ memcached@2.2.2
added 6 packages from 4 contributors and audited 6 packages in 1.425s
found 0 vulnerabilities

STORED
Friday, November  9, 2018 09:49:01 AM UTC
START DATA READ
0 << get keyWithCrLfCrLf
0 >> VALUE keyWithCrLfCrLf 0 4
0 >> 
0 >> 
0 >> 
0 >> END
0 >> 
Friday, November  9, 2018 09:49:06 AM UTC
FINISHED
#~/memcacheTest#

Callback is never called. No data, even no error, it just freezes in case when you have string containing CR-LF sequences.

Looks like it's fixed in https://github.com/3rd-Eden/memcached/pull/295/files

mapleeit commented 5 years ago

@drull755 , Thanks a lot for digging in. This is definitely a bug and should be fixed.

But I'm not sure that the problem @Himanshu44ec06 encountered is the same one. Could you provide an example of the VALUE?