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

Channel locked when using RPC #58

Open
ajudi opened this issue Nov 24, 2017 · 0 comments
Open

Channel locked when using RPC #58

ajudi opened this issue Nov 24, 2017 · 0 comments

Comments

@ajudi
Copy link

ajudi commented Nov 24, 2017

I get the following error when trying to use the RPC implementation in coworkers:

Error: Channel closed by server: 405 (RESOURCE-LOCKED) with message "RESOURCE_LOCKED - cannot obtain exclusive access to locked queue 'amq.gen-_G_bE-7udUZ7m6c9seUx0A' in vhost '/'"
    at Channel.C.accept (/home/tom/Programming/AuthServer/node_modules/amqplib/lib/channel.js:406:17)
    at Connection.mainAccept [as accept] (/home/tom/Programming/AuthServer/node_modules/amqplib/lib/connection.js:64:33)
    at Socket.go (/home/tom/Programming/AuthServer/node_modules/amqplib/lib/connection.js:477:48)
    at emitNone (events.js:106:13)
    at Socket.emit (events.js:208:7)
    at emitReadable_ (_stream_readable.js:513:10)
    at emitReadable (_stream_readable.js:507:7)
    at addChunk (_stream_readable.js:274:7)
    at readableAddChunk (_stream_readable.js:250:11)
    at Socket.Readable.push (_stream_readable.js:208:10)
    at TCP.onread (net.js:594:20)
coworkers up and consuming messages
/home/tom/Programming/AuthServer/node_modules/throw-next-tick/index.js:3
    throw err;

This is my server side code:

const coworkers = require('coworkers');
const db = require('./model/database');
const {getBearerToken} = require('./auth/oAuth2');

const app = coworkers();
app.prefetch(100);
app.queue('bearer-token-request', function * (){
    this.ack = true
    const exists = yield this.checkReplyQueue();
    if (!exists){
        this.nack
        return 
    }
    const content = this.message.content;
    console.log(content);
    this.reply(new Buffer('this is the reply'))
    this.ack = true
});

app.on('error', (err)=>{
    console.log(err.stack)
});

db.connect((err)=>{
    if(err){
        console.log('Unable to connect to the database.');
        process.exit(1);
    } else {
        app.connect((err)=>{
            if (err) return console.log(err)
            console.log('coworkers up and consuming messages')
        });
    }
});

and I'm just testing it with the following in a node terminal:

var amqplib = require('amqplib')
var request = require('amqplib-rpc').request

amqplib.connect().then(function (connection) {
  return request(connection, 'bearer-token-request', { a: 10, b: 20 }).then(function (replyMessage) {
    console.log('res',replyMessage.content.toString()) // 200
  })
}).catch((err)=>{console.log('err',err)})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant