Closes any open connection and creates a new connection with the AMQP broker.

AMQPConnection::isConnected
AMQPConnection::setHost
AMQPConnection
PHP Manual

# AMQPConnection::reconnect

(PECL amqp >= Unknown)

AMQPConnection::reconnect — Closes any open connection and creates a new connection with the AMQP broker.

### Description

public bool AMQPConnection::reconnect ( void )

This method will close any open connections and initiate a new connection with the AMQP broker.

### Parameters

This function has no parameters.

### Return Values

Returns `TRUE` on success or `FALSE` on failure.

### Examples

Example #1 AMQPConnection::reconnect() example

`<?php
/* Create a new connection */
$cnn = new AMQPConnection();
// set the login details
$cnn->setLogin('mylogin');
$cnn->setPassword('mypass');
$cnn->connect();
// do something interesting
// ensure we have a valid connection
if (!$cnn->reconnect()) {
echo "Could not reconnect to server";
}
?>`

AMQPConnection::isConnected
AMQPConnection::setHost
AMQPConnection
PHP Manual