amqplib-rpc
amqplib-rpc copied to clipboard
TypeError: connection.createChannel(...).then is not a function
Getting this for callback api of amqplib
Can you see if you can find a test that should break?
You are using the channel model everywhere in your test units, at the same time I can see an example for callback model on your module's page. Just try use exactly callback api of amqplib while creating connection to see the error message above.
See line 72 in your /lib/request.js A connection that created with callback api does not contain function 'then', but no any way to create a new channel which is applicable for callback api of amqplib in this script.
Could you split your code into two separate script implementing callback and promises api as it is done in amqplib?
You can use the following code to test the issue:
var amqplib = require('amqplib/callback_api'); var amqprpc = require('amqplib-rpc'); var sync = require('synchronize');
sync(amqplib, 'connect'); sync(amqprpc, 'request');
var request = amqprpc.request; var message = {a:5, b:4};
var config = { hostname: '127.0.0.1', port: 5672, username: 'utest', password: 'upass' };
var conn, reply;
sync.fiber( function() {
try {
conn = amqplib.connect(config);
reply = request(conn, 'multiply-queue', message, { timeout: 30000 });
console.log('rpc reply:', reply);
conn.close();
} catch (error) {
console.log('rpc call error:', error);
if (conn) {
conn.close();
};
};
});
One last question, what version of amqplib are you using? On Mon, Mar 20, 2017 at 5:13 AM lukinsv [email protected] wrote:
You can use the following code to test the issue:
var amqplib = require('amqplib/callback_api'); var amqprpc = require('amqplib-rpc'); var sync = require('synchronize');
sync(amqplib, 'connect'); sync(amqprpc, 'request');
var request = amqprpc.request; var message = {a:5, b:4};
var config = { hostname: '127.0.0.1', port: 5672, username: 'utest', password: 'upass' };
var conn, reply;
sync.fiber( function() {
try { conn = amqplib.connect(config); reply = request(conn, 'multiply-queue', message, { timeout: 30000 }); console.log('rpc reply:', reply); conn.close(); } catch (error) { console.log('rpc call error:', error); if (conn) { conn.close(); }; };
});
— You are receiving this because you commented.
Reply to this email directly, view it on GitHub https://github.com/tjmehta/amqplib-rpc/issues/16#issuecomment-287742406, or mute the thread https://github.com/notifications/unsubscribe-auth/AAnFF9HBPzRCIe-Sv2Q6cYEmr_iV02GWks5rnm1hgaJpZM4Mh8Mn .
The latest one - 2.0.4
oh, amqplib - 0.5.1
You may want to try a later version of amqplib in the meanwhile if it's possible. I have a feeling that may be causing the issue. On Mon, Mar 20, 2017 at 10:09 AM lukinsv [email protected] wrote:
oh, amqplib - 0.5.1
— You are receiving this because you commented.
Reply to this email directly, view it on GitHub https://github.com/tjmehta/amqplib-rpc/issues/16#issuecomment-287829108, or mute the thread https://github.com/notifications/unsubscribe-auth/AAnFFz47m-euKeAIC8b4iNV5m24y_j-1ks5rnrLbgaJpZM4Mh8Mn .
This is the latest version in it's repo https://github.com/squaremo/amqp.node
The issue is you are creating a new channel with 'channel' connection version, which uses promises
line72: var promise = connection.createChannel().then(function (channel) {
The 'callback' version of 'connection' has no 'then' function. So, you have to completely rework the 'response' module to support the callback version of amqplib.connection object.
Gotcha, I have a min to check this out right now. Taking a look.
@lukinsv I fixed this in #17, let me know that branch works for you.
Thanks!