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

Unhandled 'error' event #28

Closed
duartemadueno opened this issue Nov 22, 2012 · 7 comments
Closed

Unhandled 'error' event #28

duartemadueno opened this issue Nov 22, 2012 · 7 comments

Comments

@duartemadueno
Copy link

Hi guys,

I wanna handle this error when it is being emitted but i can't. Can you help me?

I'm using NodeJS v0.8.14 on a Windows machine.

I understand this error but i'm doing a dynamic 'listener' so i don't have any fixed exchange created.

Thanks,

Duarte Madueño

events.js:71
throw arguments[1]; // Unhandled 'error' event
^
Error: PRECONDITION_FAILED - cannot redeclare exchange 'testNODE' in vhost '/' w
ith different type, durable, internal or autodelete value
at Exchange._onMethod - amqp.js:2091:15
at Exchange.Channel._onChannelMethod amqp.js:1533:14
at Connection._onMethod - amqp.js:1056:28
at AMQPParser.self.addListener.parser.onMethod - amqp.js:895:12
at AMQPParser._parseMethodFrame - amqp.js:449:10
at frameEnd - amqp.js:190:16
at frame - amqp.js:175:14
at AMQPParser.header [as parse] - amqp.js:162:14
at AMQPParser.execute - amqp.js:234:21
at Connection. - amqp.js:932:12

@squaremo
Copy link
Owner

squaremo commented Dec 7, 2012

Are you using only rabbit.js? This error probably means testNODE has been declared from elsewhere, e.g., by using the Node AMQP client directly at some point. rabbit.js more or less assumes that won't be the case; i.e., that it has free range to declare what it likes (all AMQP programs have to assume this, in practice).

@duartemadueno
Copy link
Author

Yes, i'm only using rabbit.js. I know why the error is being thrown but would like to handle that specific exception so i can return a custom message to the client.

The solution was:

  • process.on('uncaughtException', function (err) {});

Anyway, this isn't the best solution, as you might see.

@squaremo
Copy link
Owner

Ah I see. It's quite tricky to handle AMQP errors, since any error tends to invalidate the AMQP channel, meaning you have to construct a new one and start things again. But you are right that rabbit.js could probably do a lot better than let exceptions be unhandled all the way up.

@duartemadueno
Copy link
Author

Since this is just a small project there's no problem working things this way but, it's true, would really handy if we could handle AMQP errors through rabbit.js

Another thing, hope you guys don't mind but i changed socket.js file so it can receive a RoutingKey on write. In my case, i don't know which RoutingKeys will be used by the client.

@squaremo
Copy link
Owner

@duartemadueno master branch now has error reporting on sockets; basically, if an AMQP channel reports an error, any socket using it will emit an error and close. If you've not moved on from rabbit.js, would you try it out to see if it works like you'd expect? Extra test cases very welcome. Thanks!

@duartemadueno
Copy link
Author

Hi @squaremo right now i'm using https://github.com/postwait/node-amqp and that solved my problem. Sorry i can't help you on this particular issue

@squaremo
Copy link
Owner

squaremo commented May 2, 2013

No worries! I understand -- it's more flexible using node-amqp directly, if a bit more work too.
Thanks for pointing out the problem in the first place.

@squaremo squaremo closed this as completed May 2, 2013
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

2 participants