noodlefrenzy / node-amqp10

amqp10 is a promise-based, AMQP 1.0 compliant node.js client
MIT License
134 stars 56 forks source link

Connection callback is never executed #81

Closed veselov closed 9 years ago

veselov commented 9 years ago

With this simple code:

var AMQ = require('amqp10');

var amq = new AMQ();

amq.connect('amqp://localhost/hello-world', function(err){
    console.log('connect callback');
    if (err) { throw err; }
 );

console.log('connect scheduled');

function die() {
    setTimeout(die, 1000);
}
die();

the only output is connect scheduled. The strace shows:

socket(PF_INET, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, IPPROTO_IP) = 10
connect(10, {sa_family=AF_INET, sin_port=htons(5672), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EINPROGRESS (Operation now in progress)
write(10, "AMQP\0\1\0\0", 8) = 8
read(10, "AMQP\1\1\0\n", 65536) = 8
read(10, "", 65536)         = 0
close(10)                   = 0

So, the AMQP conversation ended, and most likely unsuccessfully, but call back was never executed with either success or error.

For info, this is trying against qpidd. node v0.10.32 amqp10 1.0.2

noodlefrenzy commented 9 years ago

Hey, sorry for the lag in getting to this issue - I have the flu and I'm a bit out of it. This definitely looks like an invalid response from qpidd, but as you said at the very least I should be calling the callback with an error in that case.

Have you tried running with your DEBUG env var set to "amqp10-*"? That should output all of the details from my library as to what it's trying to do.

In the meantime, I'll see if I can't repro this on my end - sorry I'll be a bit slow due to the flu.

veselov commented 9 years ago

No rush :) You are right - the reason the library can't connect is legitimate. But callback is not called. I played around with this, and it seems that callback is not called for simpler problems as well.

broker isn't even running:

[vps@druid]~/ws/EF/qpids$ DEBUG=amqp10-Connection  node publish.js 
  amqp10-Connection Connecting to localhost:5672 via straight-up sockets +0ms
  amqp10-Connection Transitioning from DISCONNECTED to START due to connect +2ms
connect scheduled
  amqp10-Connection Error from socket: Error: connect ECONNREFUSED +3ms
  amqp10-Connection Transitioning from START to DISCONNECTED due to error +1ms

broker reports unsupported version:

[vps@druid]~/ws/EF/qpids$ DEBUG=amqp10-Connection  node publish.js 
  amqp10-Connection Connecting to localhost:5672 via straight-up sockets +0ms
  amqp10-Connection Transitioning from DISCONNECTED to START due to connect +2ms
connect scheduled
  amqp10-Connection Sending Header 414d515000010000 +2ms
  amqp10-Connection Transitioning from START to HDR_SENT due to connected +0ms
  amqp10-Connection Rx: 414d51500101000a +1ms
  amqp10-Connection Server AMQP Version: 414d51500101000a vs 414d515000010000 +0ms
  amqp10-Connection Transitioning from HDR_SENT to DISCONNECTING due to invalidVersion +1ms
  amqp10-Connection Transitioning from DISCONNECTING to DISCONNECTED due to terminated +1ms
noodlefrenzy commented 9 years ago

I was failing to trigger an error event on certain cases in connection.js (probably more information than you wanted). I've just published an update (1.0.3) - let me know if that solves your issue.

noodlefrenzy commented 9 years ago

Closing. Feel free to reopen if I didn't actually fix it, but I believe I have.

veselov commented 9 years ago

Thank you! Works fine for me in 1.0.3 :+1: Sorry it took me a while to check this out.

ZECTBynmo commented 9 years ago

@veselov what was the cause of your version mismatch? I'm experiencing the same thing

mbroadst commented 9 years ago

@ZECTBynmo my guess is that you don't have AMQP 1.0 support enabled for qpidd (you need to build qpidd with proton, the default ubuntu packages have this enabled). Out of the box qpidd opts to use AMQP 0-10

ZECTBynmo commented 9 years ago

Thanks @mbroadst ! How can I enable 1.0 support?

mbroadst commented 9 years ago

@ZECTBynmo well this is getting into qpid support territory, but first you'd have to tell me what distro your running on, as well as what version of qpidd

ZECTBynmo commented 9 years ago

I really appreciate the help @mbroadst

I'm running on a vagrant vm with CentOS release 6.5 (Final) I'm not sure how to figure out exactly which version of qpid I have installed, but I just yesterday with:

yum install -y qpid-cpp-server qpid-tools
mbroadst commented 9 years ago

qpidd --version will help here

ZECTBynmo commented 9 years ago

qpidd (qpidc) version 0.14

mbroadst commented 9 years ago

@ZECTBynmo that's an incredibly old version, I've only been testing our library against 0.32 (and 0.28 for a little bit, but considerably less time spent there)

mbroadst commented 9 years ago

not sure where to point you exactly (other than their irc channel #qpid, or the mailing list), but its developed mostly by redhatters iirc so you should be able to get updated packages

ZECTBynmo commented 9 years ago

Ohh okay that makes sense then. Thanks for your help!

mbroadst commented 9 years ago

@ZECTBynmo also, to explicitly enable amqp 1.0 you can pass --protocols amqp1.0 to qpidd. If you also pass --log-enable debug+ you can see if there's a message about loading the amqp1.0 module. Again, there have been countless fixes and improvements since 0.14 so I recommend first and foremost you update to that

ZECTBynmo commented 9 years ago

You're the man @mbroadst !