-
Notifications
You must be signed in to change notification settings - Fork 488
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
uncaught error: 348 trailing bytes #17
Comments
So we have narrowed this down. https://github.com/automattic/socket.io-emitter#emitterclient-opts says to set return_buffers to true on your redis client. This should fix this issue. We need to add support to socket.io-redis to see if the incoming/outcoming data is binary before sending it to msgpack. |
It worked! Thank you! |
maybe on the README we could "enforce" a bit more that parameter! i also missed the |
I have same problem.
In app.js
I get the following in my console:
|
peter chexk the return_buffers option, that should sort your issue. |
@peternguyen1991 please refer here: #61 (commits) Your problem was that Ruby's |
i saw the trailing bytes issue the first time on my app today.
is there a permanent fix available for all these issues? |
ok found the issue. |
@aschmid so is the solution to simply rollback one of these modules versions, or did you find another way? |
@stephengardner i didn't have time to look into a 'proper' solution yet so my fix was to use v1.0.0 of https://www.npmjs.com/package/redis. |
In my setup, node 4.1.1, socket-io 0.1.4, node_redis 2.0.1 the problem is that index.js line 92 expect "channel" to be a string, but it's a Buffer. |
set up redis ver. 1.0.0... is trailing bytes error fixed.. i think, that issue is node_redis 2.0.1 bug. modify your file(pakage.json) redis version " 1.* " in dependencies |
I am still getting this issue even when I set my |
I used the same package versions as PerMoeller and got his exact issue:
|
…g with socket.io socketio/socket.io-redis-adapter#17 sometimes they are back
I'm still having this error with
And it works ok with redis of 1.0.0. |
Same issue here with redis v2.2.5, socket.io v1.3.7 and socket.io-redis v0.1.4. // Server
redis.createClient(redisOptions.port, redisOptions.host, {
detect_buffers: true,
return_buffers: true,
auth_pass: redisOptions.password
});
// Client
socket.emit('echo', {content: 'A'}); And I'm getting this error:
Hope it helps |
I have this issue with the following versions node: v4.2.1 I am emitting an event with the socket.io-php-emitter with msgpack and redis
|
Update: Switching dependenices from msgpack-js to msgpack-js-v5 fixed this problem for me. It looks like php's msgpack module has been updated to the spec, but the version used by msgpack has not. |
Does this bug have anything to do with redis version after 3.0.6? |
After several experiments, my service works fine with
Just for reference |
Same error here. Nothing fixes :( |
I've same problem. but the version suggested by @StevenRoan is works fine. I've test it using socket.io-reids version is 1.0.0.
case 1. detect_buffer: true, return_buffers: trueNoError. But Subscription is not working. case 2. detect_buffer: true, return_buffers: falsemessage Pack Error. if (decoder.offset !== buffer.length) throw new Error((buffer.length - decoder.offset) + " trailing bytes"); case 3. detect_buffer: false, return_buffers: trueSame case 2. case 3. detect_buffer: false, return_buffers: falseSame case 2. |
Resolved it. It's my mistake.;; detect_buffer, return_buffer options are not same in Pub and Sub. @StevenRoan, @terion-name check your options in Pub/Sub Clients. here is my code that is working.
function create(options) {
if (config.redis.password) {
options.auth_pass = config.redis.password;
}
const client = require('redis').createClient(config.redis.port, config.redis.host, options);
const promise = require('bluebird');
promise.promisifyAll(client);
return client;
}
function createClient() {
const options = {
detect_buffers: true,
return_buffers: false
};
return create(options);
}
function createPub() {
const options = {
detect_buffers: true,
return_buffers: false
};
return create(options);
}
function createSub() {
const options = {
return_buffers: true
};
return create(options);
} |
I'm also having the same issue, and it's very easy to replicate. index.js: var io = require('socket.io')(3000);
var redisIO = require('socket.io-redis');
var redis = require('redis');
var config = {
redis: {
host: '10.0.1.231',
port: 6379
},
room: 'client1'
};
var pub = redis.createClient(config.redis.port, config.redis.host, {return_buffers: true});
var sub = redis.createClient(config.redis.port, config.redis.host, {return_buffers: true});
io.adapter(redisIO({
host: config.redis.host,
port: config.redis.port,
pubClient: pub,
subClient: sub
}));
io.on('connection', function(socket) {
console.log('connected');
socket.on('getMessages', function(){
console.log('published');
pub.publish('coolMessages', 'yolo message');
});
});
sub.subscribe('coolMessages');
sub.on('message', function(channel, data){
console.log('message!'); // this doesn't run
}); package.json: {
"name": "test_dm",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "MIT",
"dependencies": {
"redis": "^2.3.0",
"socket.io": "^1.4.5",
"socket.io-redis": "^1.0.0"
}
} just creat these two files, do a npm install. Then for the client: <!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Socket.IO Chat Example</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<ul class="pages">
<li class="chat page">
<div class="chatArea">
<ul class="messages"></ul>
</div>
<input class="inputMessage" placeholder="Type here..."/>
</li>
<li class="login page">
<div class="form">
<h3 class="title">What's your nickname?</h3>
<input class="usernameInput" type="text" maxlength="14" />
</div>
</li>
</ul>
<script src="https://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="bower_components/socket.io-client/socket.io.js"></script>
<script>
$(function() {
var socket = io('http://localhost:3000');
socket.on('connect', function () {
console.log(socket.id);
});
socket.emit('getMessages')
});
</script>
</body>
</html> bower.json {
"name": "socket-test",
"description": "",
"main": "",
"moduleType": [],
"license": "MIT",
"homepage": "",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
"socket.io-client": "^1.4.5"
}
} Just create also these two files and to a bower install. |
Hi !
|
I had this issue with redis@2.4.2, but it seem to be okay after upgrading to v2.5.0 |
I have the same error with version /home/*/npm_modules/node_modules/socket.io-redis/node_modules/msgpack-js/msgpack.js:200
did anybody have a solution for this issue? |
+1 I am experiencing this issue as well |
I was able to install the v5 version of msgpack-js-v5, then change the requires statement in node_modules/socket.io-redis/index.js (around line 8) from and that worked in my setup. |
@garfieldhamilton can you tel us the version of redis and socket.io that you use? |
+1 |
@garfieldhamilton msgpack-js-v5 is not passing tests, use msgpack5 |
For those still experimenting this issue (I truly hope no one is still using these versions) the following versions made the fix for me: "redis": "1.0.0",
"socket.io": "3.0.0",
"socket.io-redis": "4.0.1", No additional configuration required. |
I am using
socket.io-emitter
to broadcast an event to a set of channels with a for loop:In the file, I have:
In
app.js
, I havesocket.io-redis
:When I try to run
exampleFunction
, I get the following uncaught error in my console:When I change
data
to be something smaller, like:I get the same error, but to a smaller number of trailing bytes. e.g.
95 trailing bytes
.The text was updated successfully, but these errors were encountered: