AMQP server closed the channel with an error
775913
def handle_ChannelClose(self, frame):
        
        # By docs:
        # The response to receiving a Close after sending Close must be to
        # send Close-Ok.
        #
        # No need for additional checks

        self.sender.send_CloseOK()
        exc = exceptions._get_exception_type(frame.payload.reply_code)
        self._close_all(exc)
168410
def close(self, channel):
        
        self.params.update({
            'channel': channel,
            })
        return FromUrl('https://slack.com/api/im.close', self._requests)(data=self.params).post()
453609
void fireOnError(ConnectionEvent e) {
        List<EventListener> listeners = changes.getListenerList(AMQP);
        for (EventListener listener : listeners) {
            ConnectionListener amqpListener = (ConnectionListener)listener;
            amqpListener.onConnectionError(e);
        }
    }
523277
def _close_connection(self, frame_in):
        
        self._set_connection_state(Stateful.CLOSED)
        if frame_in.reply_code != 200:
            reply_text = try_utf8_decode(frame_in.reply_text)
            message = (
                'Connection was closed by remote server: %s' % reply_text
            )
            exception = AMQPConnectionError(message,
                                            reply_code=frame_in.reply_code)
            self._connection.exceptions.append(exception)
1173536
function(authFailHandler, err) {
    if (_status === Status.CLOSING || _status === Status.CLOSED) return;

    _socket.writeBuf = () => {};
    _socket.flush = () => {};

    //socket has been ended without error
    if (!err) {
      err = Errors.createError(
        'socket has unexpectedly been closed',
        true,
        info,
        '08S01',
        Errors.ER_SOCKET_UNEXPECTED_CLOSE
      );
    } else {
      err.fatal = true;
      this.sqlState = 'HY000';
    }

    const packetMsgs = info.getLastPackets();
    if (packetMsgs !== '') {
      err.message += '\nlast received packets:\n' + packetMsgs;
    }

    switch (_status) {
      case Status.CONNECTING:
      case Status.AUTHENTICATING:
        const currentCmd = _receiveQueue.peekFront();
        if (currentCmd && currentCmd.stack && err) {
          err.stack +=
            '\n From event:\n' +
            currentCmd.stack.substring(currentCmd.stack.indexOf('\n') + 1);
        }
        authFailHandler(err);
        break;

      default:
        _fatalError(err, false);
    }
  }
582564
function(packet) {
    if (packet && packet.peek() === 0xff) {
      //can receive unexpected error packet from server/proxy
      //to inform that connection is closed (usually by timeout)
      let err = packet.readError(info);
      if (
        err.fatal &&
        (_status !== Status.CLOSING && _status !== Status.CLOSED)
      ) {
        this.emit('error', err);
        this.end();
      }
    } else if (_status !== Status.CLOSING && _status !== Status.CLOSED) {
      this.emit(
        'error',
        Errors.createError(
          'receiving packet from server without active commands\n' +
            'conn:' +
            (info.threadId ? info.threadId : -1) +
            '(' +
            packet.pos +
            ',' +
            packet.end +
            ')\n' +
            Utils.log(opts, packet.buf, packet.pos, packet.end),
          true,
          info,
          '08S01',
          Errors.ER_UNEXPECTED_PACKET
        )
      );
      this.destroy();
    }
  }
173579
def clientConnectionFailed(self, connector, reason):
        
        _legacy_twisted_log.msg(
            "Connection to the AMQP broker failed ({reason})",
            reason=reason.value,
            logLevel=logging.WARNING,
        )
        protocol.ReconnectingClientFactory.clientConnectionFailed(
            self, connector, reason
        )
1208474
private void fireOnClosed(ConnectionEvent e) {
        List<EventListener> listeners = changes.getListenerList(AMQP);
        for (EventListener listener : listeners) {
            ConnectionListener amqpListener = (ConnectionListener)listener;
            amqpListener.onConnectionClose(e);
        }
    }
465916
def on_connection_open_error(self, connection, error):
        
        LOGGER.critical('Could not connect to RabbitMQ (%s): %r',
                        connection, error)
        self.state = self.STATE_CLOSED
        self._reconnect()
1062673
private void closeChannelWithLoginFailure(Channel channel)
	{
		ChannelFuture future = channel.write(NettyUtils
				.createBufferForOpcode(Events.LOG_IN_FAILURE));
		future.addListener(ChannelFutureListener.CLOSE);
	}
156175
private void fireOnError(ChannelEvent e) {
        List<EventListener> listeners = changes.getListenerList(AMQP);
        for (EventListener listener : listeners) {
            ChannelListener amqpListener = (ChannelListener)listener;
            amqpListener.onError(e);
        }
    }
1159923
@Handler(channels = EncryptedChannel.class)
    public void onClosed(Closed event, IOSubchannel encryptedChannel)
            throws SSLException, InterruptedException {
        @SuppressWarnings("unchecked")
        final Optional<PlainChannel> plainChannel
            = (Optional<PlainChannel>) LinkedIOSubchannel
                .downstreamChannel(this, encryptedChannel);
        if (plainChannel.isPresent()) {
            plainChannel.get().upstreamClosed();
        }
    }
353277
def _do_close(self):
        """"""
        AMQP_LOGGER.debug('Closed channel #%d', self.channel_id)
        self.is_open = False
        channel_id, self.channel_id = self.channel_id, None
        connection, self.connection = self.connection, None
        if connection:
            connection.channels.pop(channel_id, None)
            connection._avail_channel_ids.append(channel_id)
        self.callbacks.clear()
        self.cancel_callbacks.clear()
        self.events.clear()
        self.no_ack_consumers.clear()
1271495
private void close(final SocketChannel channel, final SelectionKey key) {
    try {
      channel.close();
    } catch (Exception e) {
      // already closed; ignore
    }
    try {
      key.cancel();
    } catch (Exception e) {
      // already cancelled/closed; ignore
    }
  }
540083
def buildProtocol(self, addr):
        
        self._client = self.protocol(self._parameters, confirms=self.confirms)
        self._client.factory = self

        @defer.inlineCallbacks
        def on_ready(unused_param=None):
            """Reset the connection delay when the AMQP handshake is complete."""
            _std_log.debug("AMQP handshake completed; connection ready for use")
            self.resetDelay()
            self._client_deferred.callback(self._client)
            self._client_deferred = defer.Deferred()

            # Restart any consumer from previous connections that wasn't canceled
            # including queues and bindings, as the queue might not have been durable
            for consumer, queue, bindings in self._consumers.values():
                _std_log.info("Re-registering the %r consumer", consumer)
                yield self._client.declare_queues([queue])
                yield self._client.bind_queues(bindings)
                yield self._client.consume(consumer.callback, consumer.queue, consumer)

        def on_ready_errback(failure):
            """If opening the connection fails or is lost, this errback is called."""
            if failure.check(pika.exceptions.AMQPConnectionError, error.ConnectionDone):
                # In this case the connection failed to open. This will be called
                # if the TLS handshake goes wrong (likely) and it may be called if
                # the AMQP handshake fails. It's *probably* a problem with the
                # credentials.
                msg = (
                    "The TCP connection appears to have started, but the TLS or AMQP handshake "
                    "with the broker failed; check your connection and authentication "
                    "parameters and ensure your user has permission to access the vhost"
                )
                wrapped_failure = Failure(
                    exc_value=ConnectionException(reason=msg, original=failure),
                    exc_type=ConnectionException,
                )
                self._client_deferred.errback(wrapped_failure)
            else:
                # Some unexpected exception happened
                _std_log.exception(
                    "The connection failed with an unexpected exception; please report this bug."
                )

        self._client.ready.addCallback(on_ready)
        self._client.ready.addErrback(on_ready_errback)
        return self._client
536200
def reconnect(self):
        """"""
        parsed = urlparse.urlparse(self.amqp_url)
        port = parsed.port or 5672
        self.connection = amqp.Connection(host="%s:%s" % (parsed.hostname, port),
                                          userid=parsed.username or 'guest',
                                          password=parsed.password or 'guest',
                                          virtual_host=unquote(
                                              parsed.path.lstrip('/') or '%2F'))
        self.channel = self.connection.channel()
        try:
            self.channel.queue_declare(self.name)
        except amqp.exceptions.PreconditionFailed:
            pass
648643
def _recv_close_ok(self, method_frame):
        '''
        
        '''
        self.channel._closed = True
        self.channel._closed_cb()