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

Adding new job with socket.io socket in data results with fail #771

Open
IvanMMM opened this issue Dec 7, 2015 · 1 comment
Open

Adding new job with socket.io socket in data results with fail #771

IvanMMM opened this issue Dec 7, 2015 · 1 comment
Labels

Comments

@IvanMMM
Copy link

IvanMMM commented Dec 7, 2015

Adding new job with socket.io socket in data results with fail with empty error object.

NOT-WORKING:

io.on('connection',function(socket){
queue
.create('getPostData',{socket:socket,data:data})
.attempts(3)
.priority('critical')
.save(function(err){
if(err){
    return io.emit('getPostData',{result:false, message:'Cannot add task to queue',err:err});
    }
});
}

WORKING:

io.on('connection',function(socket){
queue
.create('getPostData',{socketId:socket.id,data:data})
.attempts(3)
.priority('critical')
.save(function(err){
if(err){
    return io.emit('getPostData',{result:false, message:'Cannot add task to queue',err:err});
    }
});
}

And then restoring socket object by it's id.

@behrad
Copy link
Collaborator

behrad commented Dec 7, 2015

I don't expect socket object to be serializable on redis. However If the error is not verbose we can make it more clear @IvanMMM
The second approach is the safe one, since you are not sure where your job would land (worker process can be a separate node.js process)

@behrad behrad added the Question label Dec 7, 2015
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

2 participants