node.js imqplib sendToQueue to RabbitMQ is hanging
<p>I have a function for queuing a message to RabbitMQ like so:</p>

<pre><code>var amqp = require('amqplib/callback_api');

var _queueURL = 'amqp://127.0.0.1';
var _toBlahBlahQueueName = 'blahblah';

var self = module.exports = {
  queueMessage: function (msgObj, callback) {
    try {
      amqp.connect(_queueURL, function (err, connection) {
        if (err) {
          callback(err);
        }

        connection.createChannel(function (err, channel) {
          if (err) {
            callback(err);
          }

          channel.assertQueue(_toBlahBlahQueueName, { durable: true }, function (err, _ok) {
            if (err) {
              callback(err);
            }

            var msg = new Buffer(JSON.stringify(msgObj));

            channel.sendToQueue(_toBlahBlahQueueName, msg, { persistent: true }, function (err, ok) {
              if (err) {
                console.log(err);
                callback(err);
              }

              console.log('published', ok);

              channel.connection.close();
              callback(null, { message: 'queued' });
            });
          });
        });
      });
    }
    catch (e) {
      console.log(e.stack);
      callback(e);
    }
  }
};
</code></pre>

<p>I am calling the function queueMessage with messages that are about 250K in length.</p>

<p>The sendToQueue call is hanging every time.  It just sits there without returning an error.  However, the message seems to get queued!</p>

<p>The server log has the error message: client unexpectedly closed TCP connection</p>

<p>Thanks for any help!</p>