TypeError: Cannot read property 'fields' of null
On an connection.on("error", function(error) ... listener I am very occasionally getting a TypeError: Cannot read property 'fields' of null
I am not sure why this happens, I am adding more logging to try get a the stack trace, it probably breaking about 1 every few million messages, so not a critical bug, just annoying.
I wonder if it's a consumer getting a null -- this happens when RabbitMQ cancels the consumer (http://www.rabbitmq.com/consumer-cancel.html). Well, we shall see -- let me know when the logging turns something up. Thanks!
I'm getting the same thing in the debug window - cannot read property "close" of null. Im connecting to a Rabbit 3.3.4 server.
This occurs because your consumer function is called with a null message when the queue which it consumes is either deleted or in a cluster scenario, the node on which the queue is located is failing/failed, which will cause the consumption to be cancelled. Basically if your consumer is cancelled by RabbitMQ (i.e the server), the consumer callback will be invoked with null.
So within the consumer function/callback, a check for if the message is null can be used to detect if the queue was either deleted or if the consumer was cancelled.
The RabbitMQ Consumer Cancel Notification docs, this similar Github issue and the Amqplib docs on channel.consume were all good pointers in resolving and understanding the issue.
@squaremo
You could actually close this issue.
I am closing this issue, because I no longer use rabbitmq. I am not sure if this has been fixed however.