/** * Connect to an AMQP broker. * * @recoil-coroutine * * @param ConnectionOptions $options Options that configure the connection. * * @return Connection The AMQP connection. * @throws ConnectionException The connection could not be established. */ public function connect(ConnectionOptions $options) : Generator { try { return (yield Recoil::timeout($this->connectionTimeout($options), $this->connectAndHandshake($options))); } catch (ChannelClosedException $e) { throw SingleConnectionException::closedUnexpectedly($options, $e); } catch (TimeoutException $e) { throw SingleConnectionException::couldNotConnect($options, 'the connection timed out', $e); } }