socket.io-redis-adapter icon indicating copy to clipboard operation
socket.io-redis-adapter copied to clipboard

msgpack-lite BUFFER_SHORTAGE Errors on 3.1.0

Open boutdemousse opened this issue 9 years ago • 6 comments

Hello,

I am facing some troubles with a working code in 2.0.1 that keeps crashing on 3.1.0. The temporary fix for me is just to downgrade, but I am sure there is a problem lying underneath.

Maybe related to #172 ?

index.js

var app = require('express')();
var server = require('http').createServer(app);
var io = require('socket.io')(server);
var redis = require("socket.io-redis");
var sticky = require('sticky-session');
io.adapter(redis({host: 'localhost', port:6379}));

sticky.listen(server,3303);

server.once('listening', function(){
    console.log('Sticky server listening to 3303')
})

package.json

  "name": "bugger",
  "version": "0.0.1",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "mocha test"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "body-parser": "^1.15.2",
    "express": "^4.14.0",
    "express-validator": "^3.1.2",
    "http": "0.0.0",
    "redis": "^2.6.5",
    "socket.io": "^1.7.2",
    "socket.io-redis": "^3.1.0",
    "socketio-sticky-session": "^0.4.2",
    "sticky-session": "^1.1.2",
    "util": "^0.10.3"
  }
}

result

1|index | Sticky server listening to 3303
1|index | Error: BUFFER_SHORTAGE
1|index |     at DecodeBuffer.reserve (/var/www/test/node_modules/msgpack-lite/lib/flex-buffer.js:64:41)
1|index |     at bin_buffer (/var/www/test/node_modules/msgpack-lite/lib/read-format.js:93:23)
1|index |     at /var/www/test/node_modules/msgpack-lite/lib/read-token.js:153:12
1|index |     at decode (/var/www/test/node_modules/msgpack-lite/lib/read-core.js:25:12)
1|index |     at map_to_obj (/var/www/test/node_modules/msgpack-lite/lib/read-format.js:52:12)
1|index |     at /var/www/test/node_modules/msgpack-lite/lib/read-token.js:159:12
1|index |     at decode (/var/www/test/node_modules/msgpack-lite/lib/read-core.js:25:12)
1|index |     at array (/var/www/test/node_modules/msgpack-lite/lib/read-format.js:81:16)
1|index |     at /var/www/test/node_modules/msgpack-lite/lib/read-token.js:159:12
1|index |     at Codec.decode (/var/www/test/node_modules/msgpack-lite/lib/read-core.js:25:12)

boutdemousse avatar Jan 18 '17 08:01 boutdemousse

Yes, I think this is related to https://github.com/socketio/socket.io-redis/issues/172. BUFFER_SHORTAGE errors seem to happen when msgpack-lite encounters a buffer that it cannot properly decode.

Can you provide a complete test case reproducing the issue?

darrachequesne avatar Jan 18 '17 09:01 darrachequesne

Hello,

The "working" sample is available here : https://github.com/Seba0917/socket.io-redis-buffer-shortage

boutdemousse avatar Jan 19 '17 08:01 boutdemousse

I'm afraid I'm not able to reproduce:

damien@laptop:~/git$ git clone [email protected]:Seba0917/socket.io-redis-buffer-shortage.git
Cloning into 'socket.io-redis-buffer-shortage'...
remote: Counting objects: 14, done.
remote: Compressing objects: 100% (13/13), done.
Receiving objects: 100% (14/14), done.
Resolving deltas: 100% (4/4), done.
remote: Total 14 (delta 4), reused 0 (delta 0), pack-reused 0
Checking connectivity... done.
damien@laptop:~/git$ cd socket.io-redis-buffer-shortage/
damien@laptop:~/git/socket.io-redis-buffer-shortage$ npm i
[email protected] /home/damien/git/socket.io-redis-buffer-shortage
├─┬ [email protected] 
│ ├─┬ [email protected] 
│ │ ├─┬ [email protected] 
│ │ │ └── [email protected] 
│ │ └── [email protected] 
│ ├── [email protected] 
│ ├── [email protected] 
│ ├── [email protected] 
│ ├── [email protected] 
│ ├── [email protected] 
│ ├─┬ [email protected] 
│ │ └── [email protected] 
│ ├── [email protected] 
│ ├── [email protected] 
│ ├── [email protected] 
│ ├── [email protected] 
│ ├─┬ [email protected] 
│ │ ├── [email protected] 
│ │ └── [email protected] 
│ ├── [email protected] 
│ ├── [email protected] 
│ ├── [email protected] 
│ ├─┬ [email protected] 
│ │ └── [email protected] 
│ ├── [email protected] 
│ ├── [email protected] 
│ ├─┬ [email protected] 
│ │ ├── [email protected] 
│ │ └── [email protected] 
│ ├── [email protected] 
│ ├── [email protected] 
│ ├─┬ [email protected] 
│ │ ├── [email protected] 
│ │ ├─┬ [email protected] 
│ │ │ ├── [email protected] 
│ │ │ └── [email protected] 
│ │ └── [email protected] 
│ ├── [email protected] 
│ ├─┬ [email protected] 
│ │ └── [email protected] 
│ ├── [email protected] 
│ └── [email protected] 
├── [email protected] 
├─┬ [email protected] 
│ ├─┬ [email protected] 
│ │ └── [email protected] 
│ ├─┬ [email protected] 
│ │ ├── [email protected] 
│ │ ├─┬ [email protected] 
│ │ │ └── [email protected] 
│ │ ├─┬ [email protected] 
│ │ │ ├── [email protected] 
│ │ │ ├── [email protected] 
│ │ │ ├── [email protected] 
│ │ │ ├── [email protected] 
│ │ │ └── [email protected] 
│ │ └─┬ [email protected] 
│ │   ├── [email protected] 
│ │   └── [email protected] 
│ ├─┬ [email protected] 
│ │ └── [email protected] 
│ ├── [email protected] 
│ ├─┬ [email protected] 
│ │ └─┬ [email protected] 
│ │   └── [email protected] 
│ ├─┬ [email protected] 
│ │ ├── [email protected] 
│ │ ├── [email protected] 
│ │ ├── [email protected] 
│ │ ├─┬ [email protected] 
│ │ │ └── [email protected] 
│ │ ├─┬ [email protected] 
│ │ │ ├── [email protected] 
│ │ │ ├── [email protected] 
│ │ │ ├─┬ [email protected] 
│ │ │ │ └── [email protected] 
│ │ │ ├── [email protected] 
│ │ │ ├── [email protected] 
│ │ │ ├── [email protected] 
│ │ │ ├── [email protected] 
│ │ │ └── [email protected] 
│ │ ├── [email protected] 
│ │ ├── [email protected] 
│ │ ├─┬ [email protected] 
│ │ │ └─┬ [email protected] 
│ │ │   └── [email protected] 
│ │ └── [email protected] 
│ └─┬ [email protected] 
│   ├── [email protected] 
│   └── [email protected] 
├─┬ [email protected] 
│ ├─┬ [email protected] 
│ │ └── [email protected] 
│ ├─┬ [email protected] 
│ │ └── [email protected] 
│ ├─┬ [email protected] 
│ │ ├── [email protected] 
│ │ ├── [email protected] 
│ │ ├── [email protected] 
│ │ └── [email protected] 
│ ├─┬ [email protected] 
│ │ ├── [email protected] 
│ │ ├── [email protected] 
│ │ └── [email protected] 
│ └── [email protected] 
└─┬ [email protected] 
  └── [email protected] 

npm WARN [email protected] No repository field.
damien@laptop:~/git/socket.io-redis-buffer-shortage$ docker run --name redis3 -p 6379:6379 -d redis:3
221d869fa5de9a70bc9355dc7dc585692894b065dd4e5003dd5cb87c20477a5a
damien@laptop:~/git/socket.io-redis-buffer-shortage$ node index.js 
Sticky server listening to 3303

You didn't provide any client code, are there some extra steps?

darrachequesne avatar Jan 19 '17 15:01 darrachequesne

Have you tried a new redis box with nothing else connected to it?

mavrick avatar Jan 20 '17 08:01 mavrick

Interestingly, the code in my repository is enough to make the bug happen with a server running Redis server v=3.0.6 sha=00000000:0 malloc=jemalloc-3.6.0 bits=64 build=687a2a319020fa42 (you may have to wait up to 5 seconds) and runs fine on a Redis server v=3.2.1 sha=00000000:0 malloc=jemalloc-3.6.0 bits=64 build=8ab9de078b62748e

Not sure if it is really related to the Redis Server version only as I have tested on two different physical servers.

Is there a way that I can give you more debugging informations ?

boutdemousse avatar Jan 23 '17 02:01 boutdemousse

Closed by https://github.com/socketio/socket.io-redis/pull/218.

darrachequesne avatar May 20 '17 04:05 darrachequesne